Peter DeWeese
Peter DeWeese

Reputation: 18333

Check for ARC in precompile

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?

Upvotes: 31

Views: 3560

Answers (1)

Dave DeLong
Dave DeLong

Reputation: 243146

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.

Upvotes: 50

Related Questions