ARC App Crashes when accessing @property form ARC

2020-06-03 06:12发布

问题:

I have a ARC (automatic-reference-counting) app that builds a static library (also ARC). The app will launch fine but when the an action is performed that reads or writes to a @property in the static library the app will crash with this error:

dyld: lazy symbol binding failed: Symbol not found: _objc_setProperty_nonatomic
  Referenced from: /var/mobile/Applications/0E7ADBB4-FFE5-4CEB-B418-8A35A92E99D4/MyApp.app/MyApp
  Expected in: /usr/lib/libobjc.A.dylib

dyld: Symbol not found: _objc_setProperty_nonatomic
  Referenced from: /var/mobile/Applications/0E7ADBB4-FFE5-4CEB-B418-8A35A92E99D4/MyApp.app/MyApp
  Expected in: /usr/lib/libobjc.A.dylib

All the advice has been about linking non-ARC libraries to ARC Apps (or vice-versa). But these are both ARC.

回答1:

The app's Base SDK was set to iOS 6 and iOS Deployment Target was set to iOS 5.0 however for the static library both the Base SDK & iOS Deployment Target were set to iOS 6.

Making sure the Base SDK & iOS Deployment Target matched in the app and library solved this problem.