Monday, January 28, 2013

Few tips on ARC Compatibility - enabling/disabling your project ARC

Most of you guyz already know what really  ARC means, but for rest of you which are unknown about it, ARC means Automatic Reference Counting, is a feature of the new LLVM 3.0 compiler and it completely replaces the manual memory management that means we do not have to worry about memory releases of the objects we create. ARC has removed the use of retain, release, autorelease keywords and it acts like a garbage collector. ARC will take care of all the memory issues, and we developer do not have to worry about it any more.


PROBLEM :
However, since ARC is a new feature in iOS development , we may find compiling errors regarding memory keywords  while we want to mix up old projects with new ARC enabled ones, or  error occurs when we want to use ARC disabled  third party libraries to our ARC enabled project. Just like in pic:




SOLUTION :
  Below are the few solutions by which you can make your project ARC compatible:

1. You can disable your whole Project ARC by going through yourProjectTarget -> Build Settings -> Objective-C Automatic Reference Counting -> set NO  , set flag to NO





2. If you want to disable ARC only to the particular source(.m) files like disabling ARC only to the third party library files  then: To disable ARC for source files in Xcode 4, select the project and the target in Xcode. Under the target "Build Phases" tab, expand the "Compile Sources" section, select the library source files(.m file) to which you want to disable ARC, then press Enter to open an edit field, and type -fno-objc-arc as the compiler flag for those files.


3. Or, you can convert your ARC disabled projects (old xcode projects) to support new ARC  feature by using Xcode's automatic  conversion tool, that can migrate your source files to ARC compatible. But, i would recommend the above two methods rather then this one.




No comments:

Post a Comment