Kane
Kane

Reputation: 908

Static library(ARC) work on non ARC app, met error: dyld: lazy symbol binding failed: Symbol not found: _objc_retainAutoreleasedReturnValue

Xcode 4.3.2 I wrote a static library, using ARC.

When I put it into a project, and test on iOS 4.3 simulator. (base on iOS 5.1, deploy target 4.3)

If the project using ARC, it works fine.

If the project not using ARC, met errors, such as:

dyld: lazy symbol binding failed: Symbol not found: _objc_retainAutoreleasedReturnValue Referenced from: /Users/cnzzmobile/Library/Application Support/iPhone Simulator/4.3.2/Applications/A4EEB0A0-AC16-402C-B426-46667225F66D/test.app/test Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/Foundation.framework/Foundation

dyld: Symbol not found: _objc_retainAutoreleasedReturnValue Referenced from: /Users/cnzzmobile/Library/Application Support/iPhone Simulator/4.3.2/Applications/A4EEB0A0-AC16-402C-B426-46667225F66D/test.app/test Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/Foundation.framework/Foundation

I searched a lot, but can't find an answer can solve this problem.

I remove jsonobjcet which only supported by iOS5, and -fobjc-arc also doesn't work.

Thanks

Upvotes: 2

Views: 1242

Answers (2)

Kane
Kane

Reputation: 908

I found add "-fobjc-arc" at "other linker flag" can solve this problem on Xcode 4.3.2 based on iOS 5.1. Because the xcode can't find the lib which support ARC to link.

Notice that: add "-fobjc-arc" at "other linker flag" not at "Compile sources".

But this still doesn't work on old version Xcode 4(snow leopard) based on iOS 4.3.

I found some lib can work on both ARC and non ARC project without adding any special setting. I'm still waiting for the answer how to do this. Write code using pure C?

Upvotes: 1

CodaFi
CodaFi

Reputation: 43330

_objc_retainAutoreleasedReturnValue is a function of iOS 5.x's version of arc. You are attempting to build this framework and run it on iOS 4.3, which requires you to specify and deploy it for iOS 4.x, which runs the "ArcLite" framework.

Upvotes: 0

Related Questions