Search code examples
iosionic-frameworkcapacitor

Capacitor: Adding IOS Entitlements without using Xcode


I'm working on an iOS app created using Capacitor and Ionic. I've built my iOS app and have manually submitted it to Apple Store / TestFlight via xcode, but during that process I had to manually add an entitlement to my app. The process in the Capacitor docs, where you edit the app entitlements in xcode, worked just fine for me. However, I would ideally like to not keep my full iOS app in source control, and as such, I would like to add my entitlements via something like the capacitor.config.json file.

so: Is it possible to set the iOS app entitlements via the capacitor.config.json file? Something like:

{
    "appId": "com.app.name",
    "appName": "app name",
    "bundledWebRuntime": false,
    "cordova":
    {
        "android":
        {
            ...
        },
        "ios":
        {
            "entitlements":{
                ...
            }
            "preferences":
            {
                ...
            }
        },
        "preferences":
        {
            ...
        }
    },
    "npmClient": "npm"
}

If it's not, is this something that I can edit in my ci pipeline, like the android or iOS app version? I'm using a script to set the version in the android manifest / ios info.plist in my azure build pipeline. I would assume editing the AppRelease.entitlements file would work pretty similarly, being an xml file.

Ionic / Cap Versions:

> ionic info

   Ionic:

   Ionic CLI       : 6.16.3 
   Ionic Framework : @ionic/react 4.11.13

Capacitor:

   Capacitor CLI      : 2.4.7
   @capacitor/android : 2.4.7
   @capacitor/core    : 2.4.7
   @capacitor/ios     : 2.4.7

Utility:

   cordova-res : not installed globally
   native-run  : not installed globally

System:

   NodeJS : v12.16.1 
   npm    : 6.13.4
   OS     : macOS Big Sur 

Solution

  • The way I have done that in the past is by using xcodebuild with an exportOptionsRelease.plist file.

    xcodebuild -exportArchive -archivePath Release.xcarchive -exportPath Release -exportOptionsPlist exportOptionsRelease.plist
    

    You should also probably consider keeping the iOS project in source control. Might save you headaches later. Capacitor even recommends it.