iOS App with Static Lib ALWAYS crashes on Launch o

2019-01-17 12:42发布

问题:

We have an App built with a static Lib we are also building for distribution. The App and Lib run fine in Xcode debugger or when loaded on the device by Xcode debugging session. The App ALWAYS crashes as soon as we put an Ad Hoc Archive build on the device. Console log statements indicate it is crashing in Lib code, but crash report not symbolicating Lib code.

  • Can't reproduce in Xcode Simulator.
  • Guard malloc, Guard Edges show nothing (but these only run in simulator).
  • No leaks
  • Using Xcode 4.3.2
  • App targets 4.3 or later.
  • Lib targets 3.0 or later.
  • Other Linker Flags = -ObjC
  • Lib set as "Optional" in Target "Link Binaries With Libraries"
  • Thumb support off (using LLVM)

Seeing 2 exceptions on console that might be of use, but so far not turning anything up on net that helps much with this:

Application 'x' exited abnormally with signal 12: Bad system call: 12 (mostly)
Application 'x' exited abnormally with signal 12: Bad system call: 11 (rarely)

We saw the comment elsewhere that static libs with Recursion have issues. But we don't had any recursion in our Lib.

Stumped, need more ideas.

回答1:

Figured it out!! after 4 days of banging heads on desk. We don't know exactly why it works but it does. In case it's helpful to others here are the settings that resolved it for us. Set these in the "Deployment" section of the Static Library Project's Build Settings:

SET "STRIP LINKED PRODUCT" (STRIP_INSTALLED_PRODUCT) = NO
SET "STRIP STYLE" = DEBUGGING SYMBOLS.

We found this by trial and error but now notice that a few discussions online re setting up an Xcode project for building iOS static libraries use this setting. No discussion as to why, but there it is.

If anyone has any thoughts on why these lib settings fix it you might want to comment on it here.



回答2:

I had a similar problem and tried changing the project build settings, but it didn't work for me. Eventually solved my problem by changing the compiler optimization level setting for the release:

In Build Settings, go to the LLVM compiler 4.2 - Code Generation section, look for the Optimization Level option and change the Release setting from Fastest, Smallest [-Os] to None [-O0].

Hope this helps!



回答3:

The chance is very high that your build settings are different between AdHoc (Release) and Debug. Did you double-check all build-settings values? Especially look at the ARC (automatic reference counting) settings.



回答4:

Debug, by loading with the Xcode debugger, your Production build (probably set to Release Build with very different optimization and code gen settings than the Debug build you are currently testing with).