Missing Provisioning Profile error when archiving using xcodebuild

Viewed 3560

to automate my app build process, I am trying to build my iOS app via command line

Build command

xcodebuild archive -project sample.xcodeproj -scheme "sample" -archivePath $PWD/archive/sample.xcarchive -destination generic/platform=iOS -UseModernBuildSystem=NO

Export Command

xcodebuild -exportArchive -archivePath $PWD/archive/sample.xcarchive -exportOptionsPlist ./ExportOptions.plist -exportPath $PWD/build -UseModernBuildSystem=NO

Following is the error

Error Domain=IDEProvisioningErrorDomain Code=9 ""sample.app" requires a provisioning profile." UserInfo={IDEDistributionIssueSeverity=3, NSLocalizedDescription="sample.app" requires a provisioning profile., NSLocalizedRecoverySuggestion=Add a profile to the "provisioningProfiles" dictionary in your Export Options property list.}

Please note that the archive from Xcode works fine. And the Info.plist file from archive folder archive/sample.xcarchive/Info.plist does not contain provisioning profiles dictionary.

As per other suggestions on google and StackOverflow, I have tried the following

  1. Changed build settings to Legacy build
  2. Removed Provisioning profiles folder from ~/Library/MobileDevice
  3. Upgraded Xcode to latest (currently 11.4)
  4. created a softling of ~/Library/MobileDevice in /Library/MobileDevice
  5. Recreated provisioning profile in developer account.

Could anyone help me get over this issue?

2 Answers

What has finally worked is to remove wildcard while mentioning the App id in the exportOptions.plist file.

<?xml version="1.0" encoding="UTF-8"?>
<dict>
    <key>provisioningProfiles</key>
    <dict>
        <key>APP_ID_WITHOUT_WILDCARD_CHAR</key>
        <string>PROVISIOING_PROFILE_NAME_AS_SEEN_BY_XCODE</string>
    </dict>
    <key>method</key>
    <string>app-store</string>
    <key>signingCertificate</key>
    <string>iPhone Distribution</string>
    <key>signingStyle</key>
    <string>manual</string>
    <key>stripSwiftSymbols</key>
    <true/>
    <key>teamID</key>
    <string>TEAM_ID</string>
    <key>uploadSymbols</key>
    <true/>
</dict>
</plist>
Related