[How to] Turn off ARC for Selected Files or 3rd Party Libraries in XCode 4.2






This is probably the first time I’m writing something related to code development. With the introduction of iOS 5, Apple released the next version of its IDE – XCode 4.2.

XCode 4.2 came with many major changes. Developers used to XCode 4 or XCode 3 will face some problems initially. The most common problem faced will be with Automatic Reference Counting and its compliance with 3rd party libraries.

Your project will simply fail to compile if you have ARC on with 3rd party libraries not updated to use ARC.

But XCode provides a way to selectively turn off ARC for individual files whilst still enjoying the perks provided by ARC in rest of your project.

Follow these steps:

1. Click on your Project in XCode.

2. Select your project under “Targets” and click on the “Build Phases” tab.

3. Expand the Compile Sources section

4. Command+Select the files which you want to exclude from ARC.

4. Once you’ve selected the files you want press the Return (Enter) key on your keyboard.

5. In the window that appears type in “-fno-objc-arc” (without quotes) and press the Return key again.

Click to Enlarge

6. That’s it! You’re done. Clean and Build your project again and it should compile fine this time.