With the release of Xcode 8, Apple introduced a new way of managing the signing configuration. Now you have two options Manual
and Automatic
.
According to the WWDC 2016 Session about Code signing (WWDC 2016 - 401 - What's new in Xcode app signing), when you select Automatic
signing, Xcode is going to:
But according to what Apple says in that session, the Automatic Signing
is going to use Development signing
and will be limited to Xcode-created provisioning profiles.
The issue comes when you try to use Automatic Signing
on a CI environment (like Travis CI or Jenkins). I'm not able to figure out an easy way to keep using Automatic and sign for Distribution (as Xcode forces you to use Development and Xcode-created provisioning profiles).
The new "Xcode-created provisioning profiles" do not show up in the developer portal, although I can find then in my machine... should I move those profiles to the CI machine, build for Development
and export for Distribution
? Is there a way to override the Automatic Signing
using xcodebuild
?
After trying a few options, these are the solutions that I was able to use on my CI server:
Using Automatic signing
forces you to use a Developer
certificate and auto-generated provisioning profiles
. One option is to export your development certificate and private key (Application -> Utilities -> Keychain Access) and the auto-generated provisioning profiles to the CI machine. A way to locate the auto-generated provisioning profiles is to navigate to ~/Library/MobileDevice/Provisioning\ Profiles/
, move all files to a backup folder, open Xcode and archive the project. Xcode will create auto-generated development provisioning profiles and will copy them to the Provisioning Profiles
folder.
xcodebuild archive ...
will create a .xcarchive
signed for Development
. xcodebuild -exportArchive ...
can then resign the build for Distribution
Before calling xcodebuild
a workaround is to replace all instances of ProvisioningStyle = Automatic
with ProvisioningStyle = Manual
in the project file. sed
can be used for a simple find an replace in the pbxproj
file:
sed -i '' 's/ProvisioningStyle = Automatic;/ProvisioningStyle = Manual;/' <ProjectName>.xcodeproj/project.pbxproj
@thelvis also created a Ruby script to do this using the xcodeproj
gem. The script gives you a better control over what is changed.
xcodebuild
will then use the code signing identity (CODE_SIGN_IDENTITY
) set in the project, as well as the provisioning profiles (PROVISIONING_PROFILE_SPECIFIER
). Those settings can also be provided as parameters to xcodebuild
and they will override the code signing identity and/or provisioning profile set in the project.
EDIT: with Xcode 9,
xcodebuild
has a new build settings parameterCODE_SIGN_STYLE
to select betweenAutomatic
andManual
so there's no need to find and replace instances of automatic with manual in the project file, more info in WWDC 2017 Session 403 What's New in Signing for Xcode and Xcode Server
Manual signing will provide total control over the code signing identities and provisioning profiles being used. It's probably the cleanest solution, but with the downside of losing all the benefits of Automatic signing.
To learn more about code signing with Xcode 8 I really recommend this article as well as the WWDC2016 session 401 - What's new in Xcode app signing