Disabling the ARC in Xcode 4.2

Disabling the ARC in Xcode 4.2

With Xcode 4.2 (iOS 5) Apple introduce ARC (Automatic Reference Counting) to help with memory management. Basically you no longer need to call retain or release. However current examples/books (and (open source) libraries) are still doing it. This leads to (annoying) errors like:

ARC forbids explicit message send of ‘retain’

To get rid of this error you need to disable ARC, but how? I found this link which show how to disable it for cetain source files, but I wanted this to be a global setting.

My Kaazing colleague Richard Clark told me how to turn off ARC at the project level. Here is what you need to do in Xcode:

  1. Select your project file.
  2. You should be in the “Build settings” tab. Select the “levels” option (default is “Combined”)
  3. There’s a search field to the right of “Combined”. Enter “Automatic”
  4. Second group should be “Apple LLVM Compiler 3.0 – Language”. Second line under that controls ARC.
  5. Click that line, then in the middle column (where it says “yes”), click and choose “no”.
Now the error is gone. Great!