After upgrading xcode4.1/ios4 to xcode4.2/ios5 I am experiencing crashes while the App is loading and before it even enters main()
.
I tried everything in rjstelling and MarkGranoff's posts to no avail. I can now reproducibly cause it to not happen by turning off Guard Malloc on my debug scheme. Guard Malloc on--crash, off--no crash. I never had the problem on the device only the simulator. I applied the fixes in the post above first so I don't know if this would have fixed the problem without those changes or not. Hope this helps someone else.
An app crashing before entering main.m
can happen when a linked framework doesn't get copied, for example because the project uses Carthage and the Run Script
build phase /usr/local/bin/carthage copy-frameworks
is missing.
You can apply the linker flag conditionally to iOS SDKs but not the iPhone Simulator in XCode 4.
Select Other Linker Flags, click Add Build Setting, choose Add Conditional Setting, and apply -weak_library /usr/lib/libSystem.B.dylib just for iOS SDK.
This lets simulator builds still work.
In my case it was the -objc
flag in Other Linker Flags
. I had to remove that and it worked like a charm.
Check your linker flags. Some libraries you might have been using required a flag like this:
-weak_library /usr/lib/libSystem.B.dylib
The weak linking allowed building against iOS 4.x with a 3.x deployment target. For whatever reason, it's completely broken in the simulator now.
I seem to remember having had a similar crashing bug prior to main() being called and I tracked it to a mismatch between IBOutlets declared in app delegate vs in my nibs. Go through and check your outlets to see if any are somehow misconfigured.
-mz