29

I created a project without ARC. I want to use a third party SDK in my project. That SDK comes with ARC Support. So I want to add ARC for that third party files. I can disable ARC for all "MYProject" files by adding this flag into build phases like -fno-objc-arc.

But I may use large number of files. So it's better to add ARC for specific SDK only. So how to add ARC support for single or specific SDK files in XCode Project?

For Instance: I want to use Grid View. I'm adding GMGridView in my project and it comes with ARC support.

Dinesh Raja
  • 8,501
  • 5
  • 42
  • 81
  • Possible duplicate of [How to enable ARC for a single file](http://stackoverflow.com/questions/10523816/how-to-enable-arc-for-a-single-file) – Alex Celeste Dec 30 '15 at 16:52
  • @Leushenko It's asked before that question. – Dinesh Raja Dec 30 '15 at 17:44
  • As per meta, [age doesn't matter](http://meta.stackexchange.com/questions/147643/should-i-vote-to-close-a-duplicate-question-even-though-its-much-newer-and-ha/147651#147651). The other question is slightly clearer, although really these two are identical enough to request a merge. – Alex Celeste Dec 30 '15 at 18:17

2 Answers2

64

Add the flag -fobjc-arc to the files that you'd like to use ARC. It's just the opposite of the other.

Jason Coco
  • 77,985
  • 20
  • 184
  • 180
  • Thats great Man...Thank you so much...Can u help me to get a good toolkit for Grid View in ios with a correct documentation..I m stuck with grid view project – Dinesh Raja Jan 07 '12 at 08:11
  • @DineshRaja.MaG Sorry, I don't really know any good grid view projects. – Jason Coco Jan 07 '12 at 08:13
  • i Hope These links may help you: http://stackoverflow.com/questions/2265293/grid-view-in-iphone-sdk https://github.com/gmoledina/GMGridView – iCreative Jan 07 '12 at 08:46
  • 1
    @wasim Select the project itself in the _Project Navigator_ and make sure your target is selected. Then, select the _Build Phases_ tab, open the _Compile Sources_ section and double click the _Compiler Flags_ area to add specific compiler flags to specific translation units. You can find fully detailed instructions in the Xcode Doc Set. – Jason Coco Mar 27 '13 at 05:58
26

You add compiler flags in Targets -> Build Phases -> Compile Sources

Compile source show all file that project contain.so please add -fobjc-arc to compiler flag by double clicking on it as show in below image.

enter image description here

Chris Alan
  • 1,426
  • 14
  • 14