33

Using Xcode 4.2, how can one enable/disable "Automatic Reference Counting"?

ANSWERED Under Build Settings, flip "yes" and "no" depending whether you want ARC enabled.

enter image description here

Philipp Schlösser
  • 5,179
  • 2
  • 38
  • 52
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
  • possible duplicate of [How do you enable ARC project-wide in Xcode 4.2](http://stackoverflow.com/questions/7476692/how-do-you-enable-arc-project-wide-in-xcode-4-2) – bobobobo Sep 24 '12 at 02:06

3 Answers3

30

Globally:

Go to "Build Settings", look for "Apple LLVM compiler 3.0 - Language". Set the field "Objective-C Automatic Reference Counting" to "No".

enter image description here

For individual files:

Go to "Build Phases", select the file, double-click the "Compiler Flags" column and put "-fno-objc-arc" in it.

cli_hlt
  • 7,072
  • 2
  • 26
  • 22
  • 1
    I will, but note that ARC is not available on the Snow Leopard OSX (10.6) version of XCode 4.2 – cli_hlt Oct 15 '11 at 14:36
  • 2
    Nice answer, but you'll have a wizard's help if you go [Edit/Refactor](http://stackoverflow.com/a/7759972/111307) – bobobobo Sep 24 '12 at 02:07
8

To enable ARC per-file, you can also set your "Compiler Flags" under "Build Phases" to -fobjc-arc. Make sure your compiler is set to Apple LLVM compiler 4.x and not LLVM GCC 4.2.

Kishyr Ramdial
  • 970
  • 1
  • 9
  • 15
2

In XCode 4.6 this property has now changed to CLANG_ENABLE_OBJC_ARC

XCode 4.6 enabling Obj-C Automatic Reference Counting property

bleeckerj
  • 554
  • 7
  • 18