Take the 2-minute tour ×

I am using ARC successfully in my project. However, I have encountered a few files (e.g., in unit tests and mock objects) where the rules of ARC are a little more fragile right now. I recall hearing that there was a way to disable ARC on a per-file basis, though I have been unable to find this option.

Is this possible? How do I disable ARC on a per-file basis?

share|improve this question
add comment

10 Answers

up vote 1476 down vote accepted

It is possible to disable ARC for individual files by adding the -fno-objc-arc compiler flag for those files.

You add compiler flags in Targets -> Build Phases -> Compile Sources. You have to double click on the right column of the row under Compiler Flags. You can also add it to multiple files by holding the cmd button to select the files and then pressing enter to bring up the flag edit box.

I created a sample project that has an example: https://github.com/jaminguy/NoArc


See this answer for more info: Disable Automatic Reference Counting for Some Files

share|improve this answer
So, the place to add this flag isn't too intuitive. But, in Xcode 4, in build phases, and compile sources, there are actually two columns. One for the file name, and another for the compile flags for that one file. This is where you enter this specific compiler flag. –  casademora Jul 26 '11 at 17:58
Can you specify for a directory, i.e., for all files in a directory? What about for a Group? –  MattDiPasquale Aug 9 '11 at 13:45
No directories. Only one single file at a time in the build settings :( –  casademora Aug 9 '11 at 15:15
@casademora you cannot get enough upvotes for this piece of information. Thank you. –  theTRON Oct 28 '11 at 0:06
@casademora you can select multiple files at once - but then don't doubleclick but hit RETURN. then just add the -fno-objc-arc and it will be added to all selected files. edit just saw the answer below this one :( –  pkyeck Apr 7 '12 at 13:08
show 10 more comments

Disable ARC on MULTIPLE files:

  1. Select desired files at Target/Build Phases/Compile Sources in Xcode
  3. Type -fno-objc-arc
  4. Press Enter or Done


share|improve this answer
Thx! Been looking for this feature a long time. Double-clicking doesnt work when selected multiple rows, but pressing enter does. So weird. –  bobmoff Apr 12 '12 at 13:31
Oh wow. I'd spend all my karma to upvote this again. Thanks for sharing! –  jemmons May 4 '12 at 0:59
this seems not work on Xcode 4.3.3 anymore. double click or press enter on the selected files doesn't bring up the dialog for putting in the -fno-ojbc-arc flag, anyone has a workaround for this? –  tom Jul 25 '12 at 17:43
I had 4.3.3 and now 4.4 DP7 and it still works just fine. Try restarting Xcode, restarting machine and repair permissions. –  Tibidabo Jul 29 '12 at 7:28
add comment

For Xcode 4.3 the easier way might be: Edit/Refactor/Convert to objective-C ARC, then check off the files you don't want to be converted. I find this way the same as using the compiler flag above.

share|improve this answer
add comment

Note: if you want to disable ARC for many files, you have to:

  1. open "Build phases" -> "Compile sources"
  2. select files with "left_mouse" + "cmd" (for separated files) or + "shift" (for grouped files - select first and last)
  3. press "enter"
  4. paste -fno-objc-arc
  5. press "enter" again
  6. profit!
share|improve this answer
add comment

Just use the -fno-objc-arc flag in Build Phases>Compile Sources

share|improve this answer
add comment

It is very simple way to make individual file non-arc.

Follow below steps :

Disable ARC on individual file:


  2. Select .m file which you want make it NON-ARC PRESS ENTER Type -fno-objc-arc

Non ARC file to ARC project flag : -fno-objc-arc

enter code here

ARC file to non ARC project flag : -fobjc-arc

share|improve this answer
add comment

use -fno-objc-arc for each file in build phases

share|improve this answer
add comment

The four Mandatory Step as explained in this video

    //1. Select desired files
    //2. Target/Build Phases/Compile Sources
    //3. Type -fno-objc-arc
    //4. Done
share|improve this answer
add comment

Add flag “-fno-objc-arc”.

Simple follow steps : App>Targets>Build Phases>Compile Sources> add flag after class “-fno-objc-arc”

share|improve this answer
add comment
  1. Select Xcode project
  2. Go to targets
  3. Select the Build phases section
  4. Inside the build phases section select the compile sources.
  5. Select the file which you do not want to disable ARC and add -fno-objc-arc

Disable ARC for a particular file

share|improve this answer
add comment

protected by Joe Jul 28 '12 at 23:03

