Xcodebuild: Creating .ipa using -exportarchive always fails to find provisioning profile? - ios

Trying to create ipa from archive running the following command:
xcodebuild -exportArchive -archivePath $PWD/archive/test.xcarchive -exportOptionsPlist exportOptions.plist -exportPath $PWD/build
Always throws an error as follows though I have the profile installed:
error: exportArchive: No "iOS Ad Hoc" profiles for team 'XXXXXXXXXX' matching 'adhoc_profile' are installed.
Error Domain=IDEProfileLocatorErrorDomain Code=4 "No "iOS Ad Hoc" profiles for team 'XXXXXXXXXX' matching 'adhoc_profile' are installed." UserInfo={NSLocalizedDescription=No "iOS Ad Hoc" profiles for team 'XXXXXXXXXX' matching 'adhoc_profile' are installed., NSLocalizedRecoverySuggestion=Install a profile (by dragging and dropping it onto Xcode's dock item) or specify a different profile in your Export Options property list.}
Update: exportOptions.plist as follow
<?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> <true/>
<key>method</key>
<string>ad-hoc</string>
<key>provisioningProfiles</key>
<dict>
<key>com.app.appname</key>
<string>adhoc_profile</string> </dict>
<key>signingStyle</key>
<string>manual</string>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>XXXXXXXXXX</string>
<key>thinning</key>
<string><none></string>
</dict>
</plist>

Related

publish an xcodebuild iOS app with an healthkit based watchOS extension

I am using the xcodebuild for creating a package for publishing
The app bundle contains: the iOS app itself, the push notification extension, the watchos app with its extension.
The watchOS app is using the healthkit for retrieving heart rate data.
xcodebuild archive -configuration Release -workspace $(system.defaultworkingdirectory)/MyApp/MyApp.xcworkspace -scheme MyApp -archivePath $(system.defaultworkingdirectory)/MyAppArchive CODE_SIGNING_ALLOWED=NO
xcodebuild -exportArchive -archivePath $(system.defaultworkingdirectory)/MyAppArchive.xcarchive -exportPath $(system.defaultworkingdirectory)/Final -exportOptionsPlist $(system.defaultworkingdirectory)/MyApp/ExportOptions.plist
The ExportOptions.plist contains the info for signing the app
<?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>provisioningProfiles</key>
<dict>
<key>fit.myapp.watchkitapp.watchkitextension</key>
<string>ProvisioningProfileGUID1</string>
<key>fit.myapp.watchkitapp</key>
<string>ProvisioningProfileGUID2</string>
<key>fit.myapp.notification</key>
<string>ProvisioningProfileGUID3</string>
<key>fit.myapp</key>
<string>ProvisioningProfileGUID4</string>
</dict>
<key>signingCertificate</key>
<string>Apple Distribution: MY COMPANY</string>
<key>signingStyle</key>
<string>manual</string>
<key>method</key>
<string>app-store</string>
<key>teamID</key>
<string>MYTEAMID</string>
<key>uploadBitcode</key>
<false/>
</dict>
</plist>
The ipa file is successfully created but when the ipa file is uploaded (by Transporter app) the package analysis fails with the following errors:
Asset validation failed (90701)
Missing entitlement. watchOS app bundle 'MyApp.app/Watch/MyAppWatch.app/PlugIns/MyAppWatch Extension.appex' uses 'UIBackgroundModes' value 'workout-processing' without the required entitlement 'com.apple.developer.healthkit' signed into the bundle. (ID: cc87a6cd-2084-4712-9f45-b22b35e9574a)
Asset validation failed (90334) Invalid Code Signature Identifier. The
identifier "com.apple.WK" in your code signature for "MyAppWatch"
must match its Bundle Identifier "fit.myapp.watchkitapp" (ID:
bb9a56d3-949c-4b49-ad86-3cf7a26a91a2)
Extra note: If the build has performed directly in Xcode/Organizer then the issue is not present.
What am I missing?
How can I debug this kind of issues?

Azure Devops Pipelines - Xcode project with multiple provisioning profiles

I have configured pipeline to build an iOS app that is also an AUv3 plugin, it requires two provisioning profiles but I can't manage the Plist to allow the signature for both.
I have installed .p12 and Apple Provisioning Profiles.
This is my Xcode task:
steps:
- task: Xcode#5
displayName: 'Xcode build'
inputs:
actions: 'build'
sdk: iphoneos13.7
xcWorkspacePath: ‘project_name/project.xcworkspace'
scheme: 'project_name - All'
packageApp: true
exportPath: output/
exportOptions: plist
exportOptionsPlist: ‘file.plist'
signingOption: auto
teamId: [10-character development team ID]
useXcpretty: false
And here is my .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>provisioningProfiles</key>
<dict>
<key>com.company.product_name</key>
<string>UUID_Code</string>
<key>com.company.product_name.product_nameAUv3</key>
<string>UUID_Code</string>
</dict>
<key>signingCertificate</key>
<string>iOS Distribution</string>
<key>signingStyle</key>
<string>manual</string>
<key>method</key>
<string>app-store</string>
<key>teamID</key>
<string>**********</string>
</dict>
</plist>
but Xcode project with multiple provisioning profiles fails archive and sign:
Code Signing Error: No profiles for 'com.company.product_name.product_nameAUv3' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.company.product_name.product_nameAUv3'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild.
Code Signing Error: Code signing is required for product type 'App Extension' in SDK 'iOS 13.7'
Someone have similar setup? This seems I'm missing something.

Reach User Defined Build Settings inside exportOptionsPlist

I have a project which consists of different targets for different build environments. I'm getting IPA file on Jenkins with xcodebuild. I want to define one exportOptionsPlist file and assign a different variable for different targets. For example, for method, Dev target should have development and Prod target should have app-store. For achieving this I'm defining User-Defined settings in Build Settings.
P.S: Every target has only Debug and Release options and every target has IPA_EXPORT_METHOD.
My problem is that I'm getting below error when trying to get the IPA (Reading IPA_EXPORT_METHOD from the ExportOptionsPlist file):
Error Domain=IDEFoundationErrorDomain Code=1 "exportOptionsPlist error for key 'method': expected one of {app-store, ad-hoc, enterprise, development, validation}, but found ${IPA_EXPORT_METHOD}" UserInfo={NSLocalizedDescription=exportOptionsPlist error for key 'method': expected one of {app-store, ad-hoc, enterprise, development, validation}, but found ${IPA_EXPORT_METHOD}}
How can I get the archive:
$ xcodebuild -workspace CLI.xcworkspace -scheme CLI -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/CLI.xcarchive
How can I get the IPA:
$ xcodebuild -exportArchive -archivePath $PWD/build/CLI.xcarchive -exportOptionsPlist exportOptions.plist -exportPath $PWD/build
Export Options Plist:
<?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>${IPA_EXPORT_METHOD}</string>
<key>provisioningProfiles</key>
<dict>
<key>com.iamdeveloper.myproject.dev</key>
<string>My Provision File</string>
</dict>
<key>signingCertificate</key>
<string>iPhone Developer</string>
<key>signingStyle</key>
<string>manual</string>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>XXXXXXXXX</string>
<key>thinning</key>
<string><thin-for-all-variants></string>
</dict>
</plist>
EDIT: I can define different exportOptionsPlists for different targets. This solves my problem but I want to achieve it with one plist file.

Xcode export Step failed: IDEDistributionThinningStep

I'm using Xcode version 8.2.1 and Mac OS Sierra 10.12.2
Having issues exporting archive using Xcode build command:
xcodebuild -exportArchive -archivePath {archivePath} -exportPath {exportPath} -exportOptionsPlist {exportOptionsPlistPath}
While running this command i'm getting this issue:
[MT] IDEDistribution: Step failed: <IDEDistributionThinningStep: 0x7fa4d888ee20>: Error Domain=IDEDistributionErrorDomain Code=14 "No applicable devices found." UserInfo={NSLocalizedDescription=No applicable devices found.}
error: exportArchive: No applicable devices found.
Also when trying to export manually, and choosing export for specific device i'm getting this error :
The exportOptionsPlist file looks as follow:
<?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>method</key>
<string>enterprise</string>
</dict>
</plist>
I tried to play with the thinning param but nothing helped.
Thanks in advance
Are you still having this problem?
I recently run into this issue ... and I am still working on it. So far, I see a problem in your exportOptionsPlist file, it should also include a teamID, I mean:
<?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>method</key>
<string>enterprise</string>
<key>teamID</key>
<string>XX..XX</string>
</dict>
</plist>
Also, the error No applicable devices found might appear if one of the framework/library you app depends on, does not support bitcode but your app requires it.
I recommend you to follow this issue in fastline where it is described how to fully debug this error: https://github.com/fastlane/fastlane/issues/8737.
Regards.

Application failed codesign verification. The signature was invalid, contains disallowed entitlements, or it was not signed with a Distribution

I'm trying to push an iOS application to iTunes Connect, but I get this error when I try to validate it in Xcode:
Application failed codesign verification. The signature was invalid, contains disallowed entitlements, or it was not signed with an iPhone Distribution Certificate
I've seen loads of questions related to the same issue, but those didn't work for me. I follow every single step of Apple's Technical Note TN2250. I check that in the build settings a distribution profile is selected for release (have tried with the wildcard and a custom one for the app) and the schema is the correct one. To ensure the app was signed with that profile, I use the codesign -d -vvvv MyApp.app command, and get something like:
Executable=/Users/myuser/Library/Developer/Xcode/Archives/2012-09-17/myapp 17-09-12 09.27.xcarchive/Products/Applications/MyApp.app/MyApp
Identifier=com.example.MyApp
...
Authority=iPhone Distribution: My Company
Authority=Apple Worldwide Developer Relations Certification Authority
Authority=Apple Root CA
...
I check the entitlements, which I haven't modified, with security cms -D -i MyApp.app/embedded.mobileprovision, getting this:
<?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>ApplicationIdentifierPrefix</key>
<array>
<string>PR3F1X</string>
</array>
<key>CreationDate</key>
<date>2012-09-17T07:20:35Z</date>
<key>DeveloperCertificates</key>
<array>
<data>
...
</data>
</array>
<key>Entitlements</key>
<dict>
<key>application-identifier</key>
<string>PR3F1X.com.example.MyApp</string>
<key>get-task-allow</key>
<false/>
<key>keychain-access-groups</key>
<array>
<string>PR3F1X.*</string>
</array>
</dict>
<key>ExpirationDate</key>
<date>2013-09-16T07:20:35Z</date>
<key>Name</key>
<string>PROFILE NAME</string>
<key>TeamIdentifier</key>
<array>
<string>PR3F1X</string>
</array>
<key>TimeToLive</key>
<integer>364</integer>
<key>UUID</key>
<string>...</string>
<key>Version</key>
<integer>1</integer>
</dict>
</plist>
The bundle id of this app looks like com.example.MyApp, and I thought the upper cases could be the problem, but changed them and it didn't do. After that, I revoked my certificates, got fresh mobileprovision profiles and went through the whole process again, with no success.
The software I'm using is Xcode 4.3.2 with Mac OS X 10.7.4
I can't see where the problem is, I'm missing something.
EDIT 1:
Does modifying the bundle ID requires I change some other setting manually?
EDIT 2:
I just made a sample app from scratch, signed it with the same certificates and everything goes smooth, so it seems that the problem is in the configuration. I'm trying to see the differences between those two project's settings, but the only remarkable ones would be that the first one is iPad only and it uses a couple of PhoneGap plugins.
I had the same problem.
You had to check your Application's Signature, see How do I check the entitlements on my Application's Signature with following:
codesign -d --entitlements - /path/to/MyGreatApp.app
It's OK and I don't know what the error you have, if you get something like:
Executable=/path/to/MyGreatApp.app/MyGreatApp
??qq?<?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>application-identifier</key>
<string>ABC123DE45.com.appleseedinc.mygreatapp</string>
<key>get-task-allow</key>
<false/>
<key>keychain-access-groups</key>
<array>
<string>ABC123DE45.com.appleseedinc.mygreatapp</string>
</array>
</dict>
</plist>
But If you get only:
Executable=/path/to/MyGreatApp.app/MyGreatApp
Then, it's a problem. Probably, you damaged the entitlements during the code resigning with codesign tool.
I've made next steps to fix it:
Archive any app in Xcode.
Choose 'Distribute ...'->'Save for Enterprise Ad-Hoc Deployment' as AppName.ipa
Unzip AppName.ipa
Create Application's Signature entitlements file:
codesign -d --entitlements :enterprise.plist Payload/PathToApp.app/
Go to the folder where uploaded app located.
Create Provisioning profile entitlements file:
security cms -D -i /path/to/the.app/embedded.mobileprovision > provision_entitlements.plist
Open provision_entitlements.plist and enterprise.plist. Modify settings of enterprise.plist , it should be equal to provision_entitlements.plist->Entitlements property. Save the changes.
When resign the app add argument --entitlements enterprise.plist to codesign tool.
codesign -fs "iPhone Distribution: My Company" APP_DIRECTORY --entitlements enterprise.plist

Resources