Correcting iOS Deployment Failures with Xamarin Visual Studio Plugin

So picture this: I am trying to get my very own C# t-shirt by compiling the Xamarin Store App using Visual Studio (Xamarin Studio on the Mac works just fine).

I am having an issue deploying the app to the iOS Simulator so I can run it. Unfortunately, the only feedback I am receiving was Deploy Failed (check the logs).

So I check the logs. Nothing. So I open a support ticket with Xamarin and Allie gives me several things to check.  Still Nada.

At this point I’m getting a bit frustrated because I am thinking it cannot be this hard, so I start digging around and do a detailed examination of any log I can find (on the PC or the Mac).


Issue Number 1

This was when I find the issue. If you open the Console App, you will see a folder called Simulator, along with sub-folders for each application that you have run via the Simulator:


I clicked on the App whose name started with XamarinStoreIOS and as you can see on the right, the error is clearly visible.

So technically, this was not a Deployment Error, but in actuality, a run-time error.  But, since the application did not start, Visual Studio reported that it did not deploy.

So that is issue number one.


Issue Number 2

Issue number two the runtime exception:

[05-Apr-2014 10:48:05] Error: Tool MonoTouch.Tools.Tools.ContentCopier failed to run
[05-Apr-2014 10:48:05] Exception: Exception type: System.InvalidOperationException
Source file ‘/Users/mitch/Library/Caches/Xamarin/mtbs/builds/XamarinStoreiOS/fc7e7851-4a32-4b43-a9e6-f68ac1ef613e/bundle/Shared/Images/button-image.png’ does not exist
  at MonoTouch.Tools.Tools.ContentCopier.RunInner (MonoTouch.Tools.Tools.RunInfo ri) [0x00000] in <filename unknown>:0 
  at MonoTouch.Tools.Tools.ToolBase.Run () [0x00000] in <filename unknown>:0 
  at Mtb.Server.Commands.Build.RunTools (System.Collections.Generic.List`1 tools, ILoggingHelper logger) [0x00000] in <filename unknown>:0

Why am I missing this file?

It turns out, the solution is in the way the file was linked into the iOS project in Visual Studio. This is the XML from the .csproj file, concerning the button-image.png file:

<BundleResource Include="..\Shared\Images\button-image.png">

The image is the same across all three projects of the Xamarin Store App so rather than just add the file to each project, they merely created a reference link to the master copy, which is in the Shared project.


The Solution

The problem is this does not seem to be properly including this file into the iOS build process so when the binary get’s to the Mac, it is not bundled into the final executable.

I also found a similar issue with the TaskyPro sample app. A similar issue existed with one of the shared text files that was referenced from the Shared project.

I corrected the issue by simply adding the button-image.png file as an item in the iOS project, which solved the immediate problem of failing to deploy and run.

A bug has been created in Bugzilla, if you’re interested.

Leave a Reply 0 comments