Search code examples
ioscode-signingprovisioning-profilexcodebuildxcode10

XcodeBuild requiring provisioning profile for Target? Error Domain=IDEProvisioningErrorDomain Code=9


Hopefully this is just some user error but it seems that xcodebuild can't find a provisioning profile for the target, I think, which I'll call MyApp, MyApp.app is the target I think

I updated my provisioning profiles, deleted all and re-added my profiles, checked on the apple dev portal and made sure all is right. I have looked through the build settings and signing info and have not found anything that works or anything to fix that I know of or have been told about by peers. I've cleaned, restarted, tried fastlane, and now I am just using xcodebuild. Here is my error:

sudo xcodebuild -exportArchive -exportOptionsPlist 
"/Users/MyName/MyApp-ios/ExportOptions.plist" -archivePath 
'/Users/MyName/Library/Developer/Xcode/Archives/2019-02-20/MyApp             
2019-02-20 15.34.28.xcarchive' -exportPath         
"/path/MyApp.ipa" -allowProvisioningUpdates
2019-02-22 09:39:26.044 xcodebuild[15743:239787] [MT] IDEDistribution: 
-[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle 
at path '/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/DEV_2019-02- 
22_09-39-26.043.xcdistributionlogs'.
error: exportArchive: "MyApp.app" requires a provisioning profile.

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

I added MyApp.app and MyApp to my provisioning profile dict and it did not work, I am just trying to build my Development scheme/config. Neither did taking an exportOptions.plist from a successful archive/build using the GUI.

ExportOptions

<plist version="1.0">
<dict>
    <key>compileBitcode</key>
    <false/>
    <key>destination</key>
    <string>export</string>
    <key>method</key>
    <string>enterprise</string>
    <key>provisioningProfiles</key>
    <dict>
        <key>com.mycompany.myappDEV</key>        
        <string>*********UUID**********</string>
        <key>com.mycompany.myappQA</key>
        <string>*********UUID**********</string>
        <key>com.mycompany.myappPROD</key>
        <string>*********UUID**********</string>
    </dict>
    <key>signingCertificate</key>
    <string>iPhone Distribution</string>
    <key>signingStyle</key>
    <string>manual</string>
    <key>stripSwiftSymbols</key>
    <true/>
    <key>teamID</key>
    <string>XXXXXXXXX</string>
    <key>thinning</key>
    <string>&lt;none&gt;</string>
</dict>
</plist>

How do I set a provisioning profile for my Target? Or what is wrong here.


Solution

  • I'm learning a lot every day but luckily a senior developer was able to help me figure out how to make xcodebuild work for me. I am using Xcode 10.0

    1. It seems that in the Build Settings my bundle identifier in Packaging needs to only contain the basic Bundle Identifier, com.mycompany.app, no suffix for DEV/QA/TEST can be added or it will fail to build an .ipa file

    2. The provisioning profiles are numerous for my company. We have one for each environment but it turns out we have a catchall profile that our app would rather use com.mycompany.* I have some more learning to do there.

    3. I used fastlane, it was what I originally wanted to do and I think to use xcodebuild I would need to insert the provisioning profile UUID as an argument there. Here is my new build_ios_app() in my fastfile that will let me build. Fastlane and xcodebuild will overwrite whatever provisioningprofile data is in your xcode and exportoptions.plist as well as other things such as export_method. By putting the PROVISIONING_PROFILE_SPECIFIER you can save yourself some trouble.

      build_app(
          workspace: "myapp.xcworkspace",
          scheme: "DEV",
          export_method: "enterprise",
          export_options: {
          signingStyle: 'manual',
          provisioningProfiles: {
              "com.mycompany.myapp" => "*****UUID*****"
          }       
      }, 
      xcargs: "PROVISIONING_PROFILE_SPECIFIER=\"*****UUID*****\""
      

      )