Convert App to ARC while ignoring files?

2019-04-07 10:07发布

I want to convert my app to ARC but I have some external librarys and frameworks that are not complaint with ARC. I know when yous start a new project using ARC, you can later specify which files to ignore. But can you do this when upgrading an existing app to ARC?

3条回答
等我变得足够好
2楼-- · 2019-04-07 10:49

in XCode, go to your active target and select the Build Phases tab. In the Compiler Flags column, set -fno-objc-arc for each of the files you don't want ARC

EDIT:

Also, to have the opposite behavior, I mean to use a file that was written using ARC inside a non ARC project, you can set the file flag to -fobjc-arc instead

There is plenty of more info regarding ARC here: http://clang.llvm.org/docs/AutomaticReferenceCounting.html#general

查看更多
Summer. ? 凉城
3楼-- · 2019-04-07 11:00

ARC may be explicitly enabled with the compiler flag -fobjc-arc. It may also be explicitly disabled with the compiler flag -fno-objc-arc. The last of these two flags appearing on the compile line "wins".

Source: http://clang.llvm.org/docs/AutomaticReferenceCounting.html

查看更多
走好不送
4楼-- · 2019-04-07 11:00

To add to Felipe's answer, if you want to add this to multiple files at once:

Select all the files you want to exclude form ARC

Press 'Enter'

The pop-up box will appear at the last file in the list

Type -fno-objc-arc

查看更多
登录 后发表回答