6

When I run code using @autorelease keyword on iOS 4.3.x it throws this error.

dyld: lazy symbol binding failed: Symbol not found: _objc_autoreleasePoolPush
  Referenced from: /Users/Eonil/Library/Application Support/iPhone Simulator/4.3.2/Applications/3782382E-293A-4D5E-86E6-28BE35CF6048/EonilCocoaComplementsTester.app/EonilCocoaComplementsTester
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/Foundation.framework/Foundation

dyld: Symbol not found: _objc_autoreleasePoolPush
  Referenced from: /Users/Eonil/Library/Application Support/iPhone Simulator/4.3.2/Applications/3782382E-293A-4D5E-86E6-28BE35CF6048/EonilCocoaComplementsTester.app/EonilCocoaComplementsTester
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/Foundation.framework/Foundation

I thought the keyword is just replacement of explicit autorelease-pool creation/deletion. Anyway it wasn't, and threw an error. Does it supported only in specific version of iOS? So where can I check the version information about this keyword?

Kirby Todd
  • 11,254
  • 3
  • 32
  • 60
eonil
  • 83,476
  • 81
  • 317
  • 516

3 Answers3

4

Are you referring to @autoreleasepool?

You can use @autoreleasepool in an app with a build target of iOS 4.3.x if you are using Xcode 4.2 and the iOS 5 SDK. Despite the transitioning to ARC guidelines stating that "ARC introduces a statement construct to the Objective-C grammar" in @autoreleasepool, which might suggest ARC is required, it goes on to say that, "This syntax is available in all Objective-C modes."

While I don't think that's particularly clear documentation, what this means is that you can use the @autoreleasepool syntax both with and without ARC—if you're using the iOS 5 SDK.

Duncan Babbage
  • 19,972
  • 4
  • 56
  • 93
  • @autoreleasepool does not require ARC. see.. http://stackoverflow.com/q/7950583/927947 – NJones Dec 07 '11 at 05:53
  • Ah interesting, have updated my answer to correct this and to highlight the key parts of the linked documentation that on first reading could be misinterpreted... like I did. :) – Duncan Babbage Dec 07 '11 at 05:59
3

Seems to be a bug in the Simulator.

Setting the deployment target to 4.2 instead of 4.2.1 worked for me.

enter image description here

Andreas Ley
  • 9,109
  • 1
  • 47
  • 57
3

just tested @autoreleasepool {} on first generation iPhone running iOS3.0 - works without problem

RolandasR
  • 3,030
  • 2
  • 25
  • 26