Code Sign error in xcodebuild archive - ios

I am trying to generate a .ipa file only through command line,
xcodebuild archive -project someproject.xcodeproj -scheme somescheme -
archivePath /somepath/someproject.xcarchive
This command still depends on the provisioning profile I have selected in xcode, and fails if a wrong profile is chosen.
The error generated is :
Code Sign error: No matching provisioning profile found: Your build settings specify a provisioning profile with the UUID “some UUID”, however, no such provisioning profile was found.
Is there a way I can make archive command independent of provisioning profile chosen in Xcode ? Or can this be a configurable parameter in the command. Do we have a file where this value is mentioned, in that case I can overwrite it.

It looks like you should be able to use an additional parameter on the xcodebuild command you mentioned above.
There is an additional option called exportProvisioningProfile that allows you to specify the provisioning profile to use.
From Apple Docs:
-exportProvisioningProfile profilename
Specifies the provisioning profile that should be used when exporting the archive.
Link to documentation:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html

Related

xcodebuild using wrong provisioning profile

I have a bash script where I am trying to automate pushing an IPA to TestFlight. Currently this script is successfully uploading to the app-store with an ad-hoc provisioning profile and not my distribution profile as such I am unable to push the build to TestFlight as it does not have the beta-reports-active key. This is easily fixable from within XCode but I have had no luck using command line which is integral to what I want to do. This is my current command trying to use manual signing:
xcodebuild archive -workspace $NAME.xcworkspace -allowProvisioningUpdates -scheme $NAME -configuration Release -archivePath ../builds/$NAME.xcarchive DEVELOPMENT_TEAM=$TEAM_ID CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY="iOS Distribution: MY_NAME" PROVISIONING_STYLE=Manual PROVISIONING_PROFILE_SPECIFIER="PROVISIONING PROFILE "
Is there a way of getting the correct provisioning profile through command line
EDIT
Examples of what I have tried:
Downloading and inserting the provisoning profile int0 ~/Library/MobileDevice/Provisioning\ profiles and then using PROVSIONING_PROFILE_SPECIFIER to point to the profile
Inserting the app-store method into the export options plist file
Creating new ExportOptions file that specifies manual signing as well as the provision profile being used - so far getting a signing error due to no provisioning profile being found
Hope this ^ is clear
I had a similar problem, I was using fastlane to push to testflight and it automatically kept pulling the wrong provisioning profile..
When I dug deeper by running
xcodebuild -showBuildSettings -workspace Freshdesk.xcworkspace -scheme <My Build scheme>
I realised that no matter what scheme I picked I kept getting the same provisioning profile in the command line.
I then dug into xcode and chanced on this parameter
This was set to staging and I could never sign my app for the app store build, I changed it to production and it fixed my problems
You can find this under "configurations" in the info tab of your project and not the target
I hope this helps!

xcode9 requires a provisioning profile

I am using xcode plugin (version 2.0.1) with jenkins to generate our builds for multiple targeted app.
With Xcode 9, our jenkins build configuration is able to generate the archive but fails to create the ipa. The error message is as follows:
Error Domain=IDEProvisioningErrorDomain Code=9 ""test.app" requires a provisioning profile." UserInfo={NSLocalizedDescription="test.app" requires a provisioning profile., NSLocalizedRecoverySuggestion=Add a profile to the "provisioningProfiles" dictionary in your Export Options property list.}
I have already added the provisioning profile inside Jenkins Custom xcodebuild arguments section by passing the PROVISIONING_PROFILE, PROVISIONING_PROFILE_SPECIFIER, CODE_SIGN_IDENTITY, CODE_SIGN_STYLE and DEVELOPMENT_TEAM however, it still shoots the same error message. Besides, I also pass the ExportOptions.plist file in the Build phases Run script option but it seems that Xcode generates its own ExportOptions.plist(enterpriseTEAMIDExport.plist) and ignores mine. When I open enterpriseTEAMIDExport.plist file it only contains the teamid and the method of export and so, it doesn't find the provisioning profile.
So, how can I tell xcode to use my ExportOptions.plist file instead? I have followed the image here but unable to find it inside Xcode 9. Also, this post doesn't relate to me.
Another important thing is that I am able to generate the ipa using my own ExportOptions.plist file from command line xcodebuild tool using this command as follows:
xcodebuild -exportArchive -archivePath archive.xcarchive -exportPath /my/export/path -exportOptionsPlist options.plist
So, I don't know why it doesn't work with Jenkins Xcode plugin.
Any help is much appreciated.
Thanks!

Xcode Plugin of Jenkins not working with Xcode9.0

I am using Xcode plugin of Jenkins which is working for Xcode 8.3 but it is not compatible with Xcode 9.0 because of changes in code signing .
I am getting the error as below :
error: exportArchive: "SwiftDemo.app" requires a provisioning profile.
Error Domain=IDEProvisioningErrorDomain Code=9 ""SwiftDemo.app" requires a provisioning profile."
UserInfo={NSLocalizedDescription="SwiftDemo.app" requires a
provisioning profile., NSLocalizedRecoverySuggestion=Add a profile to
the "provisioningProfiles" dictionary in your Export Options property
list.}
** EXPORT FAILED **
I was also getting this error. But now solved the issue. I can build successfully in Xcode9.0 and Xcode9.2.
Here are the steps mentioned below to overcome above error.
Manually generate and export the IPA file with Xcode. This will create a file name ExportOptions.plist in the exported folder.
Copy that file to workspace root folder.
In Jenkin General build settings, uncheck “Pack application, build and sign .ipa?”, and check “Generate Archive?”.
And last, add an Execute shell like this,
xcodebuild -exportArchive -archivePath ${WORKSPACE}/build/YourProject.xcarchive -exportPath ${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/archive -exportOptionsPlist ${WORKSPACE}/ExportOptions.plist
what works for me:
Keychain: Move two signing certificates (iphone dev and iphone distr) from Login to System.
make sure that "trust" property set to "system default"

xcodebuild provisioning profiles not found?

I'll try to be polite talking about xCode.
Issue:
we updated provisioning profiles because prev ones are expired.
Now I can archive/build from xCode but can't using xcodebuild (which must be the same)
I did everything:
removing, adding profiles, recreating ...
reinstalling ... restarting...
removing account, adding back and a lot more
sudo xcodebuild -scheme nl.xxx.demo.iphone -workspace xxx.xcworkspace clean build
error:
=== BUILD TARGET xxxWatchAppDemo Extension OF PROJECT xxx WITH CONFIGURATION Debug ===
Check dependencies
Code Sign error: No provisioning profiles found: No non–expired provisioning profiles were found.
But when I'm archiving or building through xCode everything is just fine, and inside ipa, embedded.mobileprovision is actually our new mobileprovision with UUID d9179316-6950-4369-94dc-b7d71bba25a1
And if I explicitly set provisioning profile - it doesn't work out:
sudo xcodebuild -scheme nl.xxx.demo.iphone -workspace xxx.xcworkspace archive PROVISIONING_PROFILE=d9179316-6950-4369-94dc-b7d71bba25a1
error
Code Sign error: No matching provisioning profile found: Your build settings specify a provisioning profile with the UUID “d9179316-6950-4369-94dc-b7d71bba25a1”, however, no such provisioning profile was found.
Not found??? Really?
I checked /Users/xxx/Library/.../Provisioning Profiles/... and it's there.
I deleted it, added, repeated it 10 times, no result.
What kind of magic it is?
Any help appreciated.
Thanks
So Jenkins has been running under buildagent user, however provisioning profiles weren't found.
I created symbolic link to my
/buildagent/Library/MobileDevice/ProvisioningProfiles/ in very root folder - /Library/.
That solved my issue

Build iOS App Extension through command line

I'm trying to build an iOS app containing an app extension from the command line. However when I use the following xcodebuild command to build:
xcodebuild -sdk iphoneos -configuration "Debug" -workspace "/Users/user/build/app_extension_demo/app_extension_demo.xcworkspace" -scheme "AppExtensionDemo" -CODE_SIGN_IDENTITY="iPhone Developer: ios developer" PROVISIONING_PROFILE=34070551-ebe8-412a-b57c-9fbdf9a42ed4 derivedDataPath "/Users/user/build/app_extension_demo/Build/Products/Debug-iphoneos" OBJROOT="/Users/user/build/app_extension_demo/Build/" SYMROOT="/Users/user/build/app_extension_demo/Build/Products" CONFIGURATION_BUILD_DIR=/Users/user/build/app_extension_demo/Build/Products/Debug-iphoneos
I get the following error:
ERROR: Code Sign error: Provisioning profile does not match bundle identifier: The provisioning profile specified in your build settings ("XC Ad Hoc: com.mycompany.AppExtensionDemo") has an AppID of "com.mycompany.AppExtensionDemo" which does not match your bundle identifier "com.mycompany.AppExtensionDemo.NumberWidget".
I'm using a provisioning profile (XC Ad Hoc: com.mycompany.AppExtensionDemo) with AppID of com.mycompany.AppExtensionDemo, but the app extension is expecting a different AppID (com.mycompany.AppExtensionDemo.NumberWidget). Everything builds fine when done through the Xcode app. I noticed that Xcode automagically created the provisioning profile for "com.mycompany.AppExtensionDemo.NumberWidget" for the app extension target. However when building through the command line, I'm not sure how to associate app extension profile to the app extension target. Any help would be appreciated!
So I've just figured this out and posted my answer here: https://stackoverflow.com/a/29605731/1153630
Basically you can set an $ENVIRONMENT_VARIABLE into the Provisioning Profile field in your targets's Build Settings and assign it from the command line instead of using PROVISIONING_PROFILE=... - have a look at my other answer for more detail.

Resources