Pragma to explicitly enable ARC?

Is there a #pragma (or otherwise some construct) to explicitly enable automatic reference counting (ARC) in an Objective-C (or Objective-C++) source file? Even better if the source file can cause compilation to fail if ARC is not enabled.

I’m starting to have a number of ARC-only source files that can be potentially shared with other projects. Most of these contain category methods to extend built-in classes. I just don’t want to accidentally include these in a non-ARC project and starts leaking out memory.

  • UICollectionView - Downloading images and effective reloading of data, like Instagram
  • CMDeviceMotion returns 0 values for magnetic field
  • EXC_BAD_ACCESS Using gmaps sdk 1.9.0, Xcode 6.4, running on 8.3 device
  • Firebase Notification Integration on cocoa os x application
  • What is the BOOL *stop argument for enumerateObjectsUsingBlock: used for?
  • Converting between C enum and XML
  • Thanks in advance!

    Solutions Collect From Internet About “Pragma to explicitly enable ARC?”

    As far as I can tell there is no way to explicitly enable or disable ARC.

    However it is possible to detect if it is enabled. Simply add the following snippet to any file that requires ARC.

    #ifndef __has_feature
      #define __has_feature(x) 0 /* for non-clang compilers */
    #if !__has_feature(objc_arc)
      #error ARC must be enabled!

    More info: