6

I'm having a compiling error in iOS Simulator 4.3 I can't actually figure it out, The error I get is:

dyld: lazy symbol binding failed: Symbol not found: _objc_retain
  Referenced from: /Users/ben/Library/Application Support/iPhone Simulator/4.3.2/Applications/75915A97-7C3D-489A-B7B0-7B6895A4B584/AppName.app/AppName
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/lib/libobjc.A.dylib

dyld: Symbol not found: _objc_retain
  Referenced from: /Users/ben/Library/Application Support/iPhone Simulator/4.3.2/Applications/75915A97-7C3D-489A-B7B0-7B6895A4B584/AppName.app/AppName
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/lib/libobjc.A.dylib

Note:
The library being referenced (libobjc.A.dylib) is actually in the 'Expected Place' The code works fine on an iOS5 device, and in iOS5 Simulator.

oberbaum
  • 2,451
  • 7
  • 36
  • 52
  • Are you using ARC in this project? Could your question be a [duplicate of this one?](http://stackoverflow.com/questions/7423489/objective-c-arc-errors-automatic-release-problems) – Michael Dautermann Nov 13 '11 at 14:09
  • not using ARC, the project is too complicated to turn it on. – oberbaum Nov 13 '11 at 14:45
  • This symbol is not in the 4.3 lib, I wonder who's requesting this. Go to both dirs and do `nm libobjc.A.dylib | grep retain`, with 4.3 you'll see only one symbol _SEL_retain. Tried to clean the project and rebuild? – ott-- Nov 13 '11 at 17:21
  • I have the exact same problem after I upgraded to XCode 5.4 and IOS 6.0. The accepted answer does not work for me. Does anybody has other ideas? – fishinear Oct 15 '12 at 13:37

2 Answers2

28

Add -fobjc-arc in Build Settings => Other Linker Flags (OTHER_LDFLAGS) for the different configurations

iwasrobbed
  • 46,496
  • 21
  • 150
  • 195
  • 1
    doesn't this force enable arc for the entire project? isn't the point to not enable arc? – stigi Jan 17 '12 at 17:10
  • 1
    No, it doesn't doesn't force it for the whole project. – mackross Feb 29 '12 at 01:34
  • 4
    You use it as a **linker** flag, not a **compiler** flag, so it doesn't affect ARC at compilation time, only at link time. – 0xced May 10 '12 at 17:49
  • this worked, but if the project has only few files that need this flag and when we can add flag for each file separately, why do we need to add this on project level? – Saqib Saud May 25 '12 at 12:42
1

This problem occurs if you use a library that uses ARC and want to build/run on older iOS 4 devices.

In Build Settings => Other Linker Flags

  • Add -fobjc-arc
  • If yet not solved, then add -weak_library /usr/lib/libobjc.A.dylib
Md Mahbubur Rahman
  • 2,065
  • 1
  • 24
  • 36