How to enable ARC project in Xcode 4.2

I have an iOS application that I want to convert to ARC . I would just use the migration tool, but it was constantly changing during the preview phase.

I know that I can use the -fobjc-arc directive for the file-based compiler, but I want to include ARC in the whole project and then disable individual classes using -fno-objc-arc ,

Newer projects in 4.2 can use ARC by default, so there should be some kind of switch there.

Can someone help me convert a project to ARC

+50
ios xcode xcode4 ios4
Sep 19 '11 at 20:10
source share
3 answers

β€œARC is available in Xcode 4.2, currently in beta, and only when compiling with Clang (akaβ€œ Apple LLVM compiler ”). A setting called, obviously,β€œ Objective-C Automatic Link Counting. ”Turn it on and release it.

If you are working on existing code, changing this parameter will result in a huge amount of errors. ARC not only manages memory for you, but it prevents you from trying to do it yourself. It is illegal to manually save / release / auto-detect when using ARC. Since Cocoa's normal non-ARC code is littered with this stuff, you get a lot of errors.

Fortunately, Xcode offers a tool to convert existing code. Choose Edit β†’ Refactoring ... β†’ Convert to Objective-C ARC ... and Xcode will guide you through the conversion of your code. Although there may be some situations where he needs help figuring out what to do, the process should be pretty much automatic. "

I took this from this link, it helped me a lot: http://www.mikeash.com/pyblog/friday-qa-2011-09-30-automatic-reference-counting.html

+65
Oct 13 '11 at 20:19
source share

Select your project or goal, and then go to Build Settings , and in the Apple LLVM compiler 3.0 - Language section, you will see the Objective-C Automatically Link Count option.

+48
Nov 12 '11 at 12:07
source share

To tow in Xcode 4.6, you will need to find "CLANG_ENABLE_OBJC_ARC" and then change it to "Yes" to enable.

+5
Aug 18 '13 at 15:04 on
source share



All Articles