How to do an ad-hoc build (iOS platform with a distribution certificate/profile) in Cordova?


#1

I used cordova 4.1.1 and recently update to Cordova 7. I am unable to do an ad-hoc build the app with a production provisioning profile. I want to create the ipa using terminal commands.

ionic cordova build ios --device --release --buildConfig=./platforms/ios/build.json

Build config file is

{
  "ios": {
    "debug": {
      "codeSignIdentity": "iPhone Developer",
      "developmentTeam": "{{Team ID}}",
      "packageType": "development",
      "provisioningProfile": "{{development provisioning profile}}",
      "buildFlag": [
        "EMBEDDED_CONTENT_CONTAINS_SWIFT = YES",
        "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
        "LD_RUNPATH_SEARCH_PATHS = \"@executable_path/Frameworks\""
      ]
    },
    "release": {
      "codeSignIdentity": "iPhone Developer",
      "developmentTeam": "{{Team ID}}",
      "packageType": "ad-hoc",
      "provisioningProfile":"{{distribution provisioning profile}}",
      "buildFlag": [
        "EMBEDDED_CONTENT_CONTAINS_SWIFT = YES",
        "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
        "LD_RUNPATH_SEARCH_PATHS = \"@executable_path/Frameworks\""
      ]
    }
  }
}

Error is,

Code Signing Error: Provisioning profile "XXXXX Dist Profile" doesn't include signing certificate 
"iPhone Developer: Sachitra Malwatte (XXXX)".

I am confused. Why we need a development certificate if we are building an ad-hoc build? Development certificate cannot be added to a distribution profile.

How to build using a production certificate and a distribution profile?

Help is very much appreciated.


#2

Hmmm.

I am using Xcode 9.2.

Latest Cordova docs says to use "codeSignIdentity": "iPhone Developer" even for release builds.
But looks like we have to use "codeSignIdentity": "iPhone Distribution"

ad-hoc build worked with this build config

{
  "ios": {
    "debug": {
      "codeSignIdentity": "iPhone Developer",
      "developmentTeam": "{{Team ID}}",
      "packageType": "development",
      "provisioningProfile": "{{development provisioning profile}}",
      "buildFlag": [
        "EMBEDDED_CONTENT_CONTAINS_SWIFT = YES",
        "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
        "LD_RUNPATH_SEARCH_PATHS = \"@executable_path/Frameworks\""
      ]
    },
    "release": {
      "codeSignIdentity": "iPhone Distribution",
      "developmentTeam": "{{Team ID}}",
      "packageType": "ad-hoc",
      "provisioningProfile":"{{distribution provisioning profile}}",
      "buildFlag": [
        "EMBEDDED_CONTENT_CONTAINS_SWIFT = YES",
        "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
        "LD_RUNPATH_SEARCH_PATHS = \"@executable_path/Frameworks\""
      ]
    }
  }
}

Wasted good amount of time to figure this out :frowning: