Automatic Reference Counting (ARC) in the latest version of Xcode/Objective-C is awesome. I can’t count the number of times (see what I did there?) I’ve missed a
release by accident. The only problem with ARC is that it has a hissy fit when you try to include libraries of code that are not ARC compliant. ARC does interoperate with manual reference counting code on a per-file basis so to fix it, just disable ARC for the files it’s complaining about. This way, some files can use arc while others don’t need to.
Just follow these steps to set the compiler flags and disable ARC on a file:
- Select your Project in the Xcode project tree (command 1).
- Select your Target in the standard editor.
- Select the Build Phases tab.
- Expand the Compile Sources section.
- Select one (or more) files you want to exclude from ARC.
- Press the return key to open the Compiler Flags popup.
-fno-objc-arcto the compiler flags.
- Select done (press the return key again)
Now, each file you had selected will have the
-fno-objc-arc compiler flag set and will not use ARC when compiled.