Search code examples
iosxcodetestflightprovisioning-profilexcodebuild

xcodebuild exportarchive: "AppStore Profile" is not an "iOS App Development" profile


I'm trying to build and export an IPA for TestFlight release. I'm running the build pipeline on Azure DevOps hosted Mac agent so I cannot use Automatic signing. (this is a Flutter app but I'm not sure that's relevant for the specific issue I'm having) This is what happens during my build steps:

  1. I install the "iPhone Distribution" certificate and "AppStore profile" on the build machine. ("AppStore profile" was generated using the "iPhone Distribution" certificate in Apple developer portal)
  2. Run the Flutter release build so it generates the xcodeproject resources required for the native xcode build.
  3. Run the "xcodebuild archive" command on the .xcworkspace. Following settings has been specified for the Release configuration of the PBXNativeTarget in my "project.pbxproj":
CODE_SIGN_IDENTITY= "iPhone Distribution: XXXXX PTY LTD (XXXXXXXXXX)";
PROVISIONING_PROFILE_SPECIFIER = "AppStore Profile";

Step 3 succeeds with ** ARCHIVE SUCCEEDED **

  1. Run the "xcodebuild -exportArchive" command with "-exportOptionsPlist XcodeTaskExportOptions.plist". The following is the contents of "XcodeTaskExportOptions.plist":
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
      <key>signingStyle</key>
      <string>manual</string>
      <key>teamID</key>
      <string>XXXXXXXX</string>
      <key>signingCertificate</key>
      <string>iPhone Distribution: XXXXX PTY LTD (XXXXXXXXXX)</string>
      <key>provisioningProfiles</key>
      <dict>
        <key>com.myproj.app</key>
        <string>AppStore Profile</string>
        <key>method</key>
        <string>app-store</string>
      </dict>
  </dict>
</plist>

Step 4 fails with following error:

...Error Domain=IDEProfileQualificationErrorDomain Code=3
"Provisioning profile "AppStore Profile" is not an "iOS App Development" profile."
UserInfo={IDEProfileQualification...

For some reason it's complaining about my "AppStore profile" not being a "development" profile. Obviously I'm trying to create an AppStore IPA for TestFlight release so I don't want to use any "development" certificates or profiles. I can't figure out what I'm doing wrong here. Appreciate any help with this. Thanks!


Solution

  • OK I figured out the mistake. It was due to a wrong format I was using in XcodeTaskExportOptions.plist. I had put the key "method" inside "provisioningProfiles". It should be moved to root level.

    The corrected plist:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
        <dict>
          <key>signingStyle</key>
          <string>manual</string>
          <key>method</key>
          <string>app-store</string>
          <key>teamID</key>
          <string>XXXXXXXX</string>
          <key>signingCertificate</key>
          <string>iPhone Distribution: XXXXX PTY LTD (XXXXXXXXXX)</string>
          <key>provisioningProfiles</key>
          <dict>
            <key>com.myproj.app</key>
            <string>AppStore Profile</string>
          </dict>
      </dict>
    </plist>