Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
I have a problem running Unit Tests (using Nunit) on a real iPhone (works fine on Simulator).
Here is how to reproduce the problem (I'm using MonoDevelop 3.0.5 and MonoTouch 6.0.6) - CODE IS ALSO ATTACHED:
1) Create a new empty MonoTouch project (single View, universal app), called "EmptyProject"
2) Following these instructions: http://docs.xamarin.com/ios/Guides/Deployment%252c_Testing%252c_and_Metrics/Touch.Unit
Add a MonoTouch Unit Tests Project, called "UnitTests".
3) Add a default new UnitTests file (with Pass, Fail, Ignore examples), called "Test1.cs"
4) Run this on the simulator and on a real iPhone and it works OK on both at this stage.
5) Now, in EmptyProject, add a method that can easily be called, eg in EmptyProjectViewController, add:
public static void Hello()
7) In the UnitTests project, add a reference to EmptyProject (Edit References > Projects tab > tick EmptyProject
8) In Test1.cs add a call to Hello:
public void Pass()
9) Now compile both EmptyProject and UnitTests
10) Run UnitTests on the simulator - all runs OK - outputs HELLO in console OK.
11) Run UnitTests on a real iPhone - it HANGS (ive tried iPhone iOS 5.1 and iPod Touch iOS 6.0 devices, they both hang).
The output is:
Please ensure your device is connected...
Connected to: Bill’s O2 iPhone
Launching /private/var/mobile/Applications/61757B02-6486-4837-96B6-74744B051C71/UnitTests.app -debugtrack -monodevelop-port 10000 -connection-mode usb
Loaded assembly: /private/var/mobile/Applications/61757B02-6486-4837-96B6-74744B051C71/UnitTests.app/Mono.Security.dll [External]
Loaded assembly: /private/var/mobile/Applications/61757B02-6486-4837-96B6-74744B051C71/UnitTests.app/System.dll [External]
Loaded assembly: /private/var/mobile/Applications/61757B02-6486-4837-96B6-74744B051C71/UnitTests.app/System.Core.dll [External]
Loaded assembly: /private/var/mobile/Applications/61757B02-6486-4837-96B6-74744B051C71/UnitTests.app/monotouch.dll [External]
Loaded assembly: /private/var/mobile/Applications/61757B02-6486-4837-96B6-74744B051C71/UnitTests.app/System.Json.dll [External]
Loaded assembly: /private/var/mobile/Applications/61757B02-6486-4837-96B6-74744B051C71/UnitTests.app/MonoTouch.Dialog-1.dll [External]
Loaded assembly: /private/var/mobile/Applications/61757B02-6486-4837-96B6-74744B051C71/UnitTests.app/MonoTouch.NUnitLite.dll [External]
Loaded assembly: /private/var/mobile/Applications/61757B02-6486-4837-96B6-74744B051C71/UnitTests.app/EmptyProject.exe
Loaded assembly: /private/var/mobile/Applications/61757B02-6486-4837-96B6-74744B051C71/UnitTests.app/UnitTests.exe
Thread started: Finalizer
and the iPhone just shows a blank screen with the status bar at the top.
Please let me know what the problem is.
I tried add the code as a ZIP of the project but it was too big (19Mbytes), but it's easy to reproduce from above anyway.
If you remove the bin and obj directories in the project directory, it should zip up to a lot less than 19 MB.
Created attachment 3032 [details]
Source code for EmptyProject
Thanks, now attached.
It's because there are two AppDelegate classes, each registered as "AppDelegate" to ObjectiveC.
At runtime it's completely random which one is picked. Comment out the [Register ("AppDelegate")] line in EmptyProject's AppDelegate.cs, and the NUnit UI shows up just fine.
Ah yes, thanks, that's the problem. I've changed the register name to
and in Main.cs:
UIApplication.Main(args, null, "TestAppDelegate");
and then all works OK.
It would be good if you could change the default setup to be something like this when someone adds a Unit Test project - or surely everyone will hit this problem?
I've changed the default app delegate to "UnitTestAppDelegate" for test projects to avoid this problem in the future.