Bug 31361 - Attempting to run app on iOS9 causes crash
Summary: Attempting to run app on iOS9 causes crash
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 8.10
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ios9/Xcode7/OSX10.11
Assignee: Bugzilla
Depends on:
Reported: 2015-06-24 16:01 UTC by srobbins103
Modified: 2015-06-25 06:23 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:

Description srobbins103 2015-06-24 16:01:15 UTC
Overview: Our app that runs fine on iOS8 crashes on iOS9. We use Xamarin Insights, which I upgraded to and installed the patch detailed in https://releases.xamarin.com/ios9-elcapitan-preview-technical-bulletin/ and this allows the app to start and code to actually run, however the crash below occurs.

This happened with iOS9 Beta 1 and Beta 2 that I just updated to.

Steps to Reproduce: It sounds - from https://forums.xamarin.com/discussion/43129/all-xamarin-apps-crash-on-ios-9#latest - that our app is doing something differently from others. Last week we had James Clancey over for a JetPack session, so he actually has a copy of our codebase if that helps you track down the problem internally.

The crash exception is as follows - for some reason the framework is looking for a ctor for our UIApplication subclass that has an IntPtr exception. It was suggested to add [Preserve] to the class, but that didn't help.

[Note that I have ********'d out our app name below]

Failed to marshal the Objective-C object 0x1345fb0a0 (type: ********Application). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type '********.iOS.********Application' does not have a constructor that takes one IntPtr argument).
  at ObjCRuntime.Runtime.MissingCtor (IntPtr ptr, IntPtr klass, System.Type type, MissingCtorResolution resolution) [0x00046] in /Users/builder/data/lanes/1899/33f69fd0/source/maccore/src/ObjCRuntime/Runtime.cs:663 
  at ObjCRuntime.Runtime.ConstructNSObject[UIApplication] (IntPtr ptr, System.Type type, MissingCtorResolution missingCtorResolution) [0x00000] in <filename unknown>:0 
  at ObjCRuntime.Runtime.GetNSObject[UIApplication] (IntPtr ptr) [0x00000] in <filename unknown>:0 
  at UIKit.UIApplication.get_SharedApplication () [0x00000] in /Users/builder/data/lanes/1899/33f69fd0/source/maccore/src/build/ios/native/UIKit/UIApplication.g.cs:934 
  at Xamarin.InsightsCore.UIObserver.ObserveStoryBoardUI () [0x00000] in <filename unknown>:0 
  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/1899/33f69fd0/source/maccore/src/Foundation/NSAction.cs:164 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/1899/33f69fd0/source/maccore/src/UIKit/UIApplication.cs:63 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0001c] in /Users/builder/data/lanes/1899/33f69fd0/source/maccore/src/UIKit/UIApplication.cs:46 
  at ********.iOS.Application.Main (System.String[] args) [0x00043] in /Users/********/Main.cs:26 

I tried adding an IntPtr ctor as that was also a suggestion in the forums and added a breakpoint, but this didn't get hit, instead got this assertion:
*** Assertion failure in -[********Application init], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3480.5/UIApplication.m:1025

Expected Results: Well, I hoped it would run like on iOS8 :)

Build Info:

=== Xamarin Studio ===

Version 5.9.4 (build 5)
Installation UUID: c510039c-2cfa-4872-af8c-4c09ce0faccf
	Mono 4.0.2 ((detached/198235d)
	GTK+ 2.24.23 (Raleigh theme)
	Package version: 400020004

=== Apple Developer Tools ===

Xcode 6.3.2 (7718)
Build 6D2105

=== Xamarin.iOS ===

Version: (Enterprise Edition)
Hash: 33f69fd
Branch: master
Build date: 2015-06-10 21:13:20-0400

=== Build Information ===

Release ID: 509040005
Git revision: 8010a90f6e246b32364e3fb46ef2c9d1be9c9a2b
Build date: 2015-06-08 16:52:06-04
Xamarin addins: 7e93e9c3503f28770f23ce1b7eafd829919f18e8

=== Operating System ===

Mac OS X 10.10.4
Darwin Kernel Version 14.4.0
    Tue May  5 14:17:52 PDT 2015
    root:xnu-2782.30.4~3/RELEASE_X86_64 x86_64

Please let me know if you need more info to track this down.
Comment 2 srobbins103 2015-06-25 02:52:39 UTC
I didn't have that latest patch at https://releases.xamarin.com/ios-hotfix-for-ios-9-preview-xcode-6/ as it was released after I submitted this bug - I had the previous preview version installed. I agree that with that latest patch installed it all works.
Thanks everyone for the fix!
Comment 3 Saurabh 2015-06-25 06:23:44 UTC
As per comment 2, the issue is resolved for Srobbins with the installation of latest patch.

Hence closing this issue.