Check for ARC in precompile

2019-01-21 16:47发布

I have an iOS refactoring library that I want to work with and without the ARC compilation option. Is there a way to detect during compilation, like with an #ifdef, if ARC is available?

1条回答
forever°为你锁心
2楼-- · 2019-01-21 17:26

Yes, you can use the following:

#if __has_feature(objc_arc)
  ...
#endif

Even if you're using the latest version of LLVM, this will only evaluate to true if you're compiling with the -fobjc-arc option.

查看更多
登录 后发表回答