Adil's Personal Blog

Using octopress! A blogging framework for hackers.

How to Disable/Enable Atomic Reference Counting (ARC) for a Single File

| Comments

Disabling ARC use case

Say you have a project which is using ARC and you have to add some code which is not ported to ARC yet, but you need the thing. How you use that? There is a way to put a flag on these files which make them work in ARC based project without crashing or anything.

  1. Go to Target -> Build Phases -> Compile Sources in Xcode
  2. Select the desired file
  3. Double click
  4. Type -fno-objc-arc
  5. PRESS ENTER

Enabling ARC use case

Say you have a project which is not using ARC yet and you want to add some code which is using ARC. Just like disabling, you can set a flag for these files to make sure they work without any issue.

  1. Go to Target -> Build Phases -> Compile Sources in Xcode
  2. Select the desired file
  3. Double click
  4. Type -fobjc-arc
  5. PRESS ENTER