How to add ARC for specific file?

2020-02-08 06:15发布

问题:

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.

回答1:

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



回答2:

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.