iOS: symbol not found _ojbc_loadweakretained while switched target to ios 4.3 (arc)
At the beginning we built our iOS app targeting 5.0+ and used ARC to simply memory management. Later for backward compatibility, we decided to support iOS 4.3. Then I just
- Installed iOS 4.3 simulator
- Modified app deployment target to 4.3
- Clean, build, run
But the app quit unexpectly with following output
dyld: Symbol not found: _objc_loadWeakRetained
Referenced from: /Users/xxx/Library/Application Support/iPhone Simulator/4.3.2/Applications/16E98912-33B5-4660-A9A3-879D92735E44/myApp.app/myApp
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/Foundation.framework/Foundation
I knew 4.3 didn't support weak reference, but it's weird that compiler never complained at compiling time, it simply crashed at runtime.
UPDATED: I used unsafe_unretained instead of weak keyword, the app ran anyway. But I got lots of warnings like
__NSAutoreleaseNoPool(): Object 0x564bd90 of class __NSArrayM autoreleased with no pool in place - just leaking"* '
Was it normal? How to eliminate these warnings?
Well, it would be interesting to see if you change the deployment target back to 5.1 if the problem goes away. My guess is it will not.
The only ways I know of to get this kind of error are:
1) is to create a concurrent NSOperation, then not provide a runloop/autorelease pool for it 2) do not create an autorelease pool in main.m 3) create a NSThread using an object that , then try to message an object on that thread without having created an autorelease pool
Assuming the problem is most likely 3), you can find out how to create a pool for the thread in this past discussion