Missing Provisioning Profile error when archiving using xcodebuild - ios

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
Changed build settings to Legacy build
Removed Provisioning profiles folder from ~/Library/MobileDevice
Upgraded Xcode to latest (currently 11.4)
created a softling of ~/Library/MobileDevice in /Library/MobileDevice
Recreated provisioning profile in developer account.
Could anyone help me get over this issue?

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>

I got the same error after upgrading to XCode 11.3. It's related to new Apple Development and Apple Distribution certificate types.
Edit provisioning profile and select use in Xcode 11.
Use this new provisioning profile to fix this error.

Related

ERROR ITMS-90171: "Invalid Bundle Structure The binary file MyApp.app/libswiftRemoteMirror.dylib is not permitted

I'm getting below error when trying to upload my ipa which is build on Jenkins.
ERROR ITMS-90171: "Invalid Bundle Structure - The binary file 'ideaPitch.app/libswiftRemoteMirror.dylib' is not permitted. Your app can’t contain standalone executables or libraries, other than the CFBundleExecutable of supported bundles. Refer to the Bundle Programming Guide at https://developer.apple.com/go/?id=bundle-structure for information on the iOS app bundle structure."
How I get the ipa on Jenkins
/usr/bin/xcodebuild -list -workspace My_App.xcworkspace
/usr/bin/xcodebuild -scheme My_App -workspace My_App.xcworkspace -configuration Release clean build CONFIGURATION_BUILD_DIR=${WORKSPACE}/build -UseModernBuildSystem=0
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${WORKSPACE}/build/My_App.app" -o ${WORKSPACE}/build/My_App${PRODUCT_VERSION}-${PRODUCT_VERSION}.ipa
ditto -c -k --keepParent -rsrc "${WORKSPACE}/build/My_App.app.dSYM" ${WORKSPACE}/build/My_App-${PRODUCT_VERSION}-${PRODUCT_VERSION}-dSYM.zip
When I get the ipa on Xcode, everything works fine. However, I need to do it on Jenkins. What can cause this problem? Thank you.
EDIT I searched SO and found some posts (like below one). However, I need to find out which line or code this problem so I can't just directly copy and paste the answer. So please don't mark it as duplicate.
ERROR ITMS-90171: "Invalid Bundle Structure The binary file APP.app/libswiftRemoteMirror.dylib is not permitted
The problem was getting the build and then iPA from It. As I searched, the correct path was archiving the project and then get iPA from the archive with xcodebuild.
The correct two line of code is;
/usr/bin/xcodebuild -quiet -workspace ${workspaceName} -scheme ${schemeName} -sdk iphoneos -configuration Release archive -archivePath ${WORKSPACE}/build/${appName}.xcarchive
/usr/bin/xcodebuild -exportArchive -archivePath ${WORKSPACE}/build/${appName}.xcarchive -exportOptionsPlist My_Project_Main_Folder/Resources/${environment}/${environment}_ExportOptions.plist -exportPath ${WORKSPACE}/build
P.S: There is a difference between PackageApplication and Xcodebuild. Xcodebuild needs an export options plist file which tells Xcodebuild, what options does it use like Certificate, Provisioning file and Bitcode Support etc..
Example Export Options Plist File:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>compileBitcode</key>
<false/>
<key>destination</key>
<string>export</string>
<key>method</key>
<string>development</string>
<key>provisioningProfiles</key>
<dict>
<key>com.iamdeveloper.myapp.dev</key>
<string>My App Development Provision</string>
</dict>
<key>signingCertificate</key>
<string>iPhone Developer</string>
<key>signingStyle</key>
<string>manual</string>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>XXXXXXXXXX</string>
<key>thinning</key>
<string><none></string>
</dict>
</plist>

xcodebuild -exportArchive fails with error Locating signing assets failed

I'm using command line xcodebuild tool to export .ipa files from Xcode archives. It was working fine up to Xcode 8.3.3. The same setup has stopped working with Xcode 9 beta. Now it fails with this error:
IDEDistribution: Step failed: <IDEDistributionSigningAssetsStep: 0x7fc309310550>: Error Domain=IDEDistributionSigningAssetStepErrorDomain Code=0 "Locating signing assets failed."
It seems Xcode 9 cannot locate the provisioning profiles, but why?
In my case the issue was solved by the next fields in the -exportOptionsPlist plist:
<dict>
<key>compileBitcode</key>
<false/>
<key>method</key>
<string>ad-hoc</string>
<key>provisioningProfiles</key>
<dict>
<key>com.my.bundle.id</key>
<string>AD_HOC_PROVISIONING_PROFILE_NAME</string>
</dict>
<key>signingCertificate</key>
<string>CERTIFICATE_HASH</string>
<key>signingStyle</key>
<string>manual</string>
<key>teamID</key>
<string>TEAM_ID</string>
</dict>
So, apparently I had to set: compileBitcode, method, provisioningProfiles, signingCertificate, signingStyle and teamID.
In your case the set of fields can be different. I have found out my set by archiving and exporting the .ipa through Xcode 9. Xcode will export its exportOptionsPlist with the ipa and show what fields it used.
More info on the fields discovery: https://blog.bitrise.io/new-export-options-plist-in-xcode-9
I was running this command:
xcodebuild -exportArchive -archivePath archive.xcarchive -exportPath /my/export/path -exportOptionsPlist options.plist
My project uses manual signing. It turns out Xcode 9 needs the provisioning profile names or UUIDs specified in options.plist in order to sign the exported .ipa file. I added this entry to my options.plist:
<key>provisioningProfiles</key>
<dict>
<key>com.myapp.bundle.id</key>
<string>My AdHoc Provisioning Profile Name</string>
</dict>
And the error "Locating signing assets failed" was gone. However there was another error:
IDEDistribution: Step failed: : Error Domain=IDEFoundationErrorDomain Code=1 "ipatool failed with an exception: #
Xcode 9 recompiles the app from bitcode by default. I got over this error by turning bitcode off by adding another entry to my options.plist:
<key>compileBitcode</key>
<false/>
Now I'm finally able to build my app with Xcode 9 and export ipa files with xcodebuild without errors.

Error: no provisioning profile matches xcode build

BuilSettings[REFERENCE IMAGE1][1]I'm creating an script to automate ios build to generate .ipa ... Below is my script,
# xcodebuild -workspace "project.xcworkspace" -scheme "Schemename" clean
# xcodebuild -workspace "project.xcworkspace" -scheme "Schemename" build
# xcodebuild archive -workspace "project.xcworkspace" -scheme "schemename" -archivePath "project.xcworkspace.xcarchive"
# xcodebuild -exportArchive -archivePath "project.xcworkspace.xcarchive" -exportPath "project.xcworkspace" -exportFormat ipa -exportProvisioningProfile "Digi Form Development": *"
while executing above script getting an error of,
--- xcodebuild: WARNING: -exportArchive without -exportOptionsPlist is deprecated error: no provisioning profile matches 'Digi Form
Development: *'
** EXPORT FAILED **
Since I'm new to this ios build deployment using xcode cli kindly help me on to correct my problems,
You need to create a exportOptions.plist file, then add the command line flag as so:
-exportOptionsPlist exportOptions.plist
The export options plist should look something like the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>compileBitcode</key>
<false/>
<key>method</key>
<string>ad-hoc</string>
<key>provisioningProfiles</key>
<dict>
<key>my.bundle.idenifier</key>
<string>My Provisioning Profile Name</string>
</dict>
<key>signingCertificate</key>
<string>iPhone Distribution</string>
<key>signingStyle</key>
<string>manual</string>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>YOURTEAMID</string>
<key>thinning</key>
<string><none></string>
</dict>
</plist>
Note that signing style can be manual or automatic. If you are explicitly setting the provisioning profile, which I tend to do, use manual and specify the provisioning profile name explicitly. If automatic, Xcode will try to automatically find a matching profile.
For the method field, the options are: development, ad-hoc, distribution and enterprise.
Here is a link with a more general description on this feature: http://devcenter.bitrise.io/tips-and-tricks/xcodebuild-export-options/

How to sign an ad-hoc iOS build without beta-reports-active entitlement?

I'm trying do an ad-hoc distribution of an app, I'm building it succesfully but getting the next error when trying to install it though iTunes:
MIS: entitlement 'beta-reports-active' has value not permitted by provisioning profile 'name_of_prov_file'
The beta-reports-active field is not set in the ad-hoc provisioning file, which is fine, but for some reason this entitlement is being added to the app in the embedded.mobileprovision file within the IPA. I think this is the problem.
I tried specifying a custom entitlements plist with:
<dict>
<key>application-identifier</key>
<string>xxxxxxxx</string>
<key>beta-reports-active</key>
<false/>
</dict>
This is showing up in the IPA in the archived-expanded-entitlements.xcent file. But the embedded.mobileprovision file still has it set to true.
I'm using these export options:
<key>method</key>
<string>ad-hoc</string>
<key>uploadSymbols</key>
<true/>
<key>teamID</key>
<string>xxxxxxxxxxxx</string>
<key>compileBitcode</key>
<false/>
And these commands:
xcodebuild -alltargets -configuration Release clean build archive -archivePath $PWD/build/archive.xcarchive -scheme projectname -sdk iphoneos9.3 "CODE_SIGN_IDENTITY=${CODE_SIGN_IDENTITY}" "CODE_SIGN_ENTITLEMENTS=entitlements.plist"
xcodebuild -exportArchive -archivePath $PWD/build/archive.xcarchive -exportPath $PWD/build/ -exportOptionsPlist exportOptions.plist
It's a Cordova application so it's not being developed with XCode and this is a Jenkins automated build.
Note: I can successfully do an app-store build for test flight, this is not what this questions is about.

xcodebuild archive fails ITMS validation

Our app has a watchkit app + extension. Archives from XCode IDE always pass iTunes store validation. However archives generated via xcodebuild command tools (Xcode 6.4; Build version 6E35b) fail this validation with the following errors:
ERROR ITMS-90163: "Invalid Code Signing Entitlements. The entitlements in your app bundle signature do not match the ones that are contained in the provisioning profile. The bundle contains a key that is not included in the provisioning profile: 'aps-environment' in 'Payload/TheDodo.app/PlugIns/DodoExtension.appex/DodoExtension'."
ERROR ITMS-90164: "Invalid Code Signing Entitlements. The entitlements in your app bundle signature do not match the ones that are contained in the provisioning profile. According to the provisioning profile, the bundle contains a key value that is not allowed: '##########.###.##########.######' for the key 'application-identifier' in 'Payload/TheDodo.app/PlugIns/TheDodoWatchKitExtension.appex/TheDodoWatchKitExtension'"
ERROR ITMS-90163: "Invalid Code Signing Entitlements. The entitlements in your app bundle signature do not match the ones that are contained in the provisioning profile. The bundle contains a key that is not included in the provisioning profile: 'aps-environment' in 'Payload/TheDodo.app/PlugIns/TheDodoWatchKitExtension.appex/TheDodoWatchKitExtension'."
ERROR ITMS-90046: "Invalid Code Signing Entitlements. Your application bundle's signature contains code signing entitlements that are not supported on iOS. Specifically, value '##########.###.##########.######' for key 'application-identifier' in 'Payload/TheDodo.app/PlugIns/TheDodoWatchKitExtension.appex/TheDodoWatchKitExtension' is not supported. This value should be a string starting with your TEAMID, followed by a dot '.', followed by the bundle identifier."
ERROR ITMS-90163: "Invalid Code Signing Entitlements. The entitlements in your app bundle signature do not match the ones that are contained in the provisioning profile. The bundle contains a key that is not included in the provisioning profile: 'aps-environment' in 'Payload/TheDodo.app/PlugIns/TheDodoWatchKitExtension.appex/TheDodoWatchKitApp.app/TheDodoWatchKitApp'."
ERROR ITMS-90163: "Invalid Code Signing Entitlements. The entitlements in your app bundle signature do not match the ones that are contained in the provisioning profile. The bundle contains a key that is not included in the provisioning profile: 'com.apple.security.application-groups' in 'Payload/TheDodo.app/PlugIns/TheDodoWatchKitExtension.appex/TheDodoWatchKitApp.app/TheDodoWatchKitApp'."
The Makefile to archive and export looks something like this:
/usr/bin/xcodebuild -verbose -verbose -workspace 'rebelmouse.xcworkspace' -scheme TheDodo -configuration "App Store" -sdk 'iphoneos' -archivePath /tmp/TheDodo.xcarchive -derivedDataPath /tmp/ROJECT.Ji9vwyH0 APPLICATION_BUILD_VERSION=2456 archive
/usr/bin/xcodebuild -exportArchive -exportFormat ipa -archivePath /tmp/TheDodo.xcarchive -exportPath /tmp/TheDodo.ipa -exportWithOriginalSigningIdentity
Any suggestion / help is very appreciated. Thanks in advance.
Answering this in case anyone else is stuck in the same boat.
With Xcode 7.0 the xcodebuild acquired a new command line option to export archive namely the exportOptionsPlist , this takes a full path to a plist that configures the archive.
You no longer need to set the -exportFormat
xcodebuild --help lists the details of the plist.
For enterprise builds I use this 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>method</key>
<string>enterprise</string>
</dict>
</plist>
For App Store builds replace replace enterprise with app-store.
tell xcodebuild the name of the provisioning profile to use instead of having it 'auto-search' it:
xcodebuild -exportArchive -exportFormat ipa -archivePath "FOLD/FILE.xcarchive" -exportPath "FOLD/FILE.ipa" -exportProvisioningProfile "NAME" > /dev/null || exit 1

Resources