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

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

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?

_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.

Related

dyld: Library not loaded: #rpath/Realm.framework/Realm error with Realm Objective C framework

I have installed the Realm Objective C Framework (2.0.3) by simply dragging it into my project created in Xcode 8. When I first tried it on simulator I got the typical dyld error.
dyld: Library not loaded: #rpath/Realm.framework/Realm
Referenced from: /var/containers/Bundle/Application/89F5987A-F3F0-45F2-9014-6BA662135E00/RelamDemo.app/RelamDemo
Reason: image not found
So I tried to fix it using the following suggestion:
https://github.com/realm/realm-cocoa/issues/1681#issuecomment-120749962
And it worked on iOS 10 Simulators.
But when I tried to run the same project on a device (iOS 10/9.3.2) I got the same dyld error again.
I have checked that I have copied the Realm.framework in my project. Now how can I solve the problem?
You need to ensure that Realm.framework is also copied to the 'Embedded Binaries' section of your app as well.
You can find that section in the 'General' tab of your project's settings.
(Screenshot courtesy of this iOSDevCenter post)

Ios :: dyld: Symbol not found: _OBJC_CLASS_$_UIAlertAction

I have an app which works fine with iOS sdk 8.3 and Xcode 6. but when i check backward compatibility with iOS sdks 7.1 and 7.1 simulator it fails.
App crashes with following error
dyld: Symbol not found: _OBJC_CLASS_$_UIAlertAction
Referenced from: /Users/apogaeis/Library/Developer/CoreSimulator/Devices/F48B2D65-9EE8-4737-A0CE-2882D105C6C9/data/Applications/25B9DCDE-4BC6-4568-8EBE-3474FE559CBC/AppName.app/AppName
Expected in: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 7.1.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/UIKit.framework/UIKit
in /Users/apogaeis/Library/Developer/CoreSimulator/Devices/F48B2D65-9EE8-4737-A0CE-2882D105C6C9/data/Applications/25B9DCDE-4BC6-4568-8EBE-3474FE559CBC/AppName.app/AppName
Please suggest to resolve the issue.
How can i make it work for all the iOS versions?
Thanks
In my case, UIKit.Framework had to be marked Optional rather than Required now my app works fine....

dyld: Symbol not found: __NSConcreteGlobalBlock after updating to OSX 10.8

I just updated to Mac OSX10.8 and I'm trying to compile a Mac app that ran perfectly when using 10.7 + Xcode 4.5. Now I get this error:
dyld: Symbol not found: __NSConcreteGlobalBlock
Expected in: /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
I've looked everywhere and things seem to be ok. The deployment target for the app is 10.6 which already supports blocks. Any ideas?
Thanks!!
It turns out that my project was trying to use an old version of the CoreServices framework which was causing this issue. I re-added all the frameworks that my project was using and the problem was gone :)
+1 on your question... Not sure if that would help finding the problem with OS X, but there is a similar error that happens with iPhone apps, with a solution in the link below. Another reason I am providing this link is that googling this error for the iPhone got me to this page.
iOS 4 app crashes at startup on iOS 3.1.3: Symbol not found: __NSConcreteStackBlock

Compiling link error with xcode 4.2 for my iphone apps

I pass to xcode 4.2 and when I compile I have this error:
ld: library not found for -lz.1.2.3
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang
failed with exit code 1.
I am assuming lz is supposed to be libz. If that is the case, you are looking for a very specific version of the lib, so you're problem can be fixed by changing it to 1.2. This is done where you add frameworks (Coredata etc) in Xcode.
Hope this helps.

ld: library not found for -lz.1.2.3

When trying to compile the software for iOS 5, XCode 4.2 throws an error:
ld: library not found for -lz.1.2.3
I found this post that tells me to replace 1.2.3. with 1.2.5
https://github.com/dbloete/ioctocat/issues/107
After doing what the link has suggested, it worked for XCode 4.2 but fails for older versions for XCode with the error
ld: library not found for -lz.1.2.5
Has anyone encountered the above situation? How can I resolve this so that it will not fail between the different versions of SDK?
Just use -lz, there's no need to use the versioned link to it. So remove libz-1.2.5.dylib from frameworks and add libz.dylib.