I have an monotouch application that includes an objective-c static library. The application runs correctly on the simulator, but when I try run the app on my iPhone 3GS, it crashes on startup. These are the steps that I have taken to try get it working:
- Compiled the static library in Xcode with Device specified and active architecture set at armv6 and at armv7 (I am not sure which is correct, but I tried both and neither worked).
- Under the project info I set code signing identity to my developer key.
In MonoDevelop I have included the static library in the application project options by setting the additional monotouch arguments under iPhone build to have the following value (this is identical to what is set for iPhoneSimulator):
-v -v -v -gcc_flags "-lstdc++ -I${ProjectDir}/Ultralite/Include -L${ProjectDir}/Ultralite -lUltralite -force_load ${ProjectDir}/Ultralite/libUltralite.a"
When I try run the application, it crashes on startup (so the application screen does not even appear). In MonoDevelop all that I see is the following exception message:
Exception of type 'Mono.Debugger.Soft.VMDisconnectedException' was thrown.
All that I see in the device log in Xcode is the following:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x2fd00f24
If I remove the -gcc_flags option from the project options, then the application starts up, but crashes at the first attempt at accessing the static library. So it is definitely something to do with the static library that is causing the application to crash on startup.
I have no idea where to even begin with solving this, and so really need some help on this one. Anyone got any ideas as to what is wrong with the static library that I am including, or know where I can get more information about what is going wrong? The KERN_PROTECTION_FAILURE message in the crash report is really not giving me much to work with.
Update: I have created a simple Hello World application which has one button, which when clicked calls a method sayHello in a static library. Even with this basic example I encountered the same problem; namely that it runs on the simulator but not on the actual device. I have uploaded my helloworld example to github. I would really appreciate it if someone could help me in getting this working. Here is the Hello World sample:
https://github.com/BruceHill/HelloWorld
This includes a folder for the basic application, a folder with the objective-c static library and then finally a folder for the btouch definition. I call btouch with the parameter -outdir=. to build Messaging.g.cs and UltraliteManager.g.cs which I then include in the MonoTouch application.