简体   繁体   中英

Difficulties getting iOS 5 app running on iOS 4

I have an iPhone app that with deployment target 4.0 and base sdk 5.0. The app runs fine on an iOS 5 simulator but when I stat the 4.3 simulator the app chrashes and I get this:

dyld: lazy symbol binding failed: Symbol not found: _objc_retainAutoreleasedReturnValue Referenced from: /Users/joakim/Library/Application Support/iPhone Simulator/4.3.2/Applications/F6CE76EA-DA7E-4BAC-A3AC-3CE2B51C0CD9/PingPalARC.app/PingPalARC Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/Foundation.framework/Foundation

dyld: Symbol not found: _objc_retainAutoreleasedReturnValue
Referenced from: /Users/joakim/Library/Application Support/iPhone Simulator/4.3.2/Applications/F6CE76EA-DA7E-4BAC-A3AC-3CE2B51C0CD9/PingPalARC.app/PingPalARC Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/Foundation.framework/Foundation

sharedlibrary apply-load-rules all (gdb)

The project does not use ARC by default, however there are a few classes for with i have turned on ARC with the -fobjc-arc flag under compile sources

I do not use any weak references and I do not use storyboards, so I can not see why my app should not work on iOS 4.x. Can anyone tell me what I have missed in order for my app to work on both iOS 4 and 5.

Added Frameworks: System Configuration Map Kit CFNetwok Core Location

You are using ARC, which is not built in to iOS 4. Did you set your deployment target to 4, so the arclite library is included for you? https://devforums.apple.com/message/588316

(Ah, it sounds like you did, but aren't telling the IDE that you are using ARC. So you will have to include it yourself.)

Not really an answer, but some more information in case it helps someone more knowledgable than me...

objc_retainAutoreleasedReturnValue(obj) is new to iOS 5 and does pretty much what the name says. Conceptually, if the nominated object is in the autorelease pool then it's taken out of there, implicitly retaining it, and a suitable release is added at a later point. So it's a way of avoiding the memory bottleneck problem that can occur when conceptually temporary objects pile up in the autorelease pool. So it's an optimisation, not a new piece of behaviour.

The ARC compiler will have inserted that in one of your ARC files where some method receives an autoreleased object. As you say, it's unrelated to both weak references and storyboards and is logically something you could simply not do in order to retain iOS 4 compatibility.

Having said all that, I'm not completely confident of a workaround other than the obvious but probably very hard to stomach — modify your ARC classes so that they never receive autoreleased objects or switch off ARC entirely. Apple don't allow dynamically linked libraries to be deployed so I can't think of a safe way to offer an objc_retainAutoreleasedReturnValue alternative for iOS 4 devices.

在函数内添加autoreleasepool块内的所有临时变量声明。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM