Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add IOS capability programmatically in Cordova plugin

I have developed a plugin for Cordova IOS, for using App Groups.

The plugin needs to activate App Groups Capability under Targets -> Capabilities in XCode and select one of the App Groups.

If I activate it manually, it works well, but I would like to activate it programmatically, well in plugin.xml, or with a custom hook.

Somebody have achieved that?

like image 410
Víctor Avatar asked May 10 '16 10:05

Víctor


1 Answers

Add the following to the plugin.xml file then remove and reinstall the plugin. The capability will still need to be added to the provisioning profile(s), but Xcode should resolve that automatically if you build using the GUI or use the -allowProvisioningUpdates flag with cordova build ios/xcodebuild.

<platform name="ios">
    <config-file target="*.entitlements"
            parent="com.apple.security.application-groups">
            <array><string>group.com.example</string></array>
    </config-file>
    <config-file target="**/Entitlements-Debug.plist"
            parent="com.apple.security.application-groups">
            <array><string>group.com.example</string></array>
    </config-file>
    <config-file target="**/Entitlements-Release.plist"
            parent="com.apple.security.application-groups">
            <array><string>group.com.example</string></array>
    </config-file>
</platform>
like image 108
NoodleOfDeath Avatar answered Oct 01 '22 14:10

NoodleOfDeath