7

Is it possible to have an iOS app that's not ARC enabled but with some arc files?

I have a non-ARC enabled app where I would like to bring in some ARC enabled files. Is this possible?

thanks

Brad Larson
  • 168,330
  • 45
  • 388
  • 563
hanumanDev
  • 6,226
  • 11
  • 76
  • 144
  • possible duplicate of [How can I disable ARC for a single file in a project?](http://stackoverflow.com/questions/6646052/how-can-i-disable-arc-for-a-single-file-in-a-project) – jscs Apr 17 '12 at 18:31
  • my question is that but in reverse. how do I move an ARC enabled file into a non-ARC project. thanks – hanumanDev Apr 18 '12 at 09:31

2 Answers2

11

You can use the -fobjc-arc flag to enable ARC for specific files.

Kemal Fadillah
  • 9,456
  • 3
  • 42
  • 60
dddsspo
  • 201
  • 2
  • 4
  • the compiler says 'unrecognized command line option for -f-objc-arc '. fyi - I'm trying to move some sample ARC compliant code into a non-ARC app. thanks – hanumanDev Apr 17 '12 at 15:42
  • Looks like there isn't supposed to be a hyphen between f and objc. Edited my answer. – dddsspo Apr 17 '12 at 15:50
  • 2
    I still get: cc1obj: error: unrecognized command line option "-fobjc-arc" thanks again – hanumanDev Apr 17 '12 at 15:58
  • @hanumanDev That is the correct way, after searching it. I feel silly for not assuming it existed :p. Where are you adding the line? – borrrden Apr 17 '12 at 23:49
  • 6
    Here's the solution to this error: You are using the wrong compiler. Go to Target Settings > Build Settings > Build Options, and change the compiler from `LLVM GCC` to `Apple LLVM`. Build and run, and the problem is solved. – Neeku Jan 28 '13 at 08:09
-1

Using the -fobjc-arc flag to enable ARC for specific files may result in an 'unrecognized command line option for -f-objc-arc error which is because of using the wrong compiler.

To fix this, go to Target Settings > Build Settings > Build Options, and change the compiler from LLVM GCC to Apple LLVM. Build and run, and the problem should be solved.

Neeku
  • 3,538
  • 8
  • 31
  • 42