Archive for September 2012
With the release of Cordova 2.1.0, CordovaLib will have been fully migrated to use Automatic Reference Counting (ARC). In a nutshell, ARC is automatic memory management for Objective-C objects and blocks (simply – you don’t have to worry about retains and releases for the most part).
What does it mean for your third-party Cordova iOS plugins?
Nothing1, if your project itself does not support ARC, and the default project template does not support ARC for Cordova iOS 2.1.0.
If you do upgrade your project itself to ARC through running the Xcode migration wizard from the menu: Edit -> Refactor -> Convert to Objective-C ARC… (then de-select libCordova.a) then you need to be aware that your plugins need to be upgraded since 99% of the plugins out there are not ARC compatible yet.
How do you get your plugin upgraded?
- The plugin author should upgrade the plugin to conditionally support ARC (through the __has_feature(objc_arc) macro) which would maintain compatibility
- You can upgrade them yourself using the Xcode migration wizard (Edit -> Refactor -> Convert to Objective-C ARC…) and selectively choose the plugin files only
- Don’t upgrade but set a compiler flag for your .m file in your Target settings to not compile your plugin for ARC. Select the Build Phases tab, expand the “Compile Sources” list, and select your .m file. Double-click in the “Compiler Flags” column, and enter the value -fno-objc-arc
 In the rare case that you encounter a plugin that is ARC only and you need to use it in your non-ARC project, do step 3 above but use the compiler flag -fobjc-arc instead.