How to Disable ARC for individual files in Xcode

ShareThis

ARC (Automatic Reference Counting) is the way to manage memory by the compiler itself without direct intervention of the programmer. Earlier memory was managed manually but Apple introduced ARC for iOS 5. But in some cases we have to use some SDK (for iPad, iPod and iPhone Development) or class files which do not support ARC e.g. Facebook SDK does not support ARC. So in this case when you compile your product, compiler will show you errors related to undesired releasing or retaining objects in class files of these APIs and product will not be compiled. As shown in figure below:

iPhone Development

So to use these kind of classes or APIs, we have to Disable ARC specifically for those files which do not support ARC.

We can disable ARC for specific files by adding some compiler flag. We can do this by Choosing "Build Phases" inside Targets same as below:

iPhone Development Disabling ARC

Now select "Compile sources" inside "Build Phases" then select those files for which you want to disable ARC and add "-fno-objc-arc" complier flag as in the figure below:

iPhone App Development

When you are done with this , Xcode will list those files with "-" sign and the compiler will work fine for those SDK also which do not support ARC.

Total votes: 173



`
Kelltontech