Enable or Disable ARC on single file in a Project

ARC (Automatic Reference Counting) was introduced in iOS 5.0 SDK.
Although there is no difference in the execution of an ARC program and a well written MRC (Manual Reference Counting), it is good to use ARC if it is annoying for you to manually keep track of reference counting of objects that you create. On other hand using ARC also decreases your line of code count.

But leaving all the advantages or disadvantages aside, during your iOS development experience you may fell into a situation when you want to enable or disable ARC base compilation for one or more files in a project but not the complete project.

You don’t have to do any hack for this just simply
1 – Go to TARGETS.
2 – Select Build Phases.
3 – Click the small arrow left to the text Compile Sources. It will open up list of all the .m files of your project.
4 – Double click the file name for which you want to enable ARC and just write this flag -fobjc-arc and you are done.
Likewise if you want to disable ARC for any file just write the flag -fno-objc-arc then this file will be compiled as a MRC file.

Leave a Reply

Your email address will not be published. Required fields are marked *