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:
- Select your project file.
- You should be in the “Build settings” tab. Select the “levels” option (default is “Combined”)
- There’s a search field to the right of “Combined”. Enter “Automatic”
- Second group should be “Apple LLVM Compiler 3.0 – Language”. Second line under that controls ARC.
- Click that line, then in the middle column (where it says “yes”), click and choose “no”.
Now the error is gone. Great!
Thanks Richard
Advertisement
Like this:
2 bloggers like this post.
Matthias, i have same problem. Try to do the same but same error still. I am still trying you have any advice for me, i appreciate!
Thanks Matthias all the way from Sydney Australia!
Thanks also from Pyrmont, Sydney Australia also
Great!
ran into the reverse problem, had set it to off at the project start and needed it on for the objective-c big nerd ranch book. This also helped me figure out how to enable, so thanks for posting this, much appreciated.
Thank you! I’m reading Cocoa and Objective C “Up and Running” It’s funny how quick printed material becomes outdated.
Very USEFULL!!!!!. . .TNX
Thanks. Although ARC is a great feature, old tutorials or classes (like CocoaAsyncSocket) do not work with it.
Thanks from finland too!
Thanks from Marlborough Connecticut, USA!
This was a big headache this morning. Got it solved with your help. Thanks!
Excellent! Worked like a charm! Thank you!
Thanks from the lowest-paid in IT, Philippines!