Configure the code signing setting of the Xcode project with the configuration settings file

When you are working on an iOS app project file and plan to distribute it as open source or sample code, you may not want to set code signing settings in the project file. However, while working locally, you need to set the code signing settings, otherwise you will not be able to install it on the device.

In such cases, it is useful to use a build configuration file for code-signing settings.

TOC

Create the build configuration file

For more information about how to create the build configuration file, please see the following article.

Using the above article as a guide, create the following three build configuration files.

  • Debug.xcconfig
  • Release.xcconfig
  • Signing.xcconfig

Set Debug.xcconfig to debug build and Release.xcconfig to release build.

Write the following in Debug.xcconfig and Release.xcconfig to include Signing.xcconfig.

#include? "Signing.xcconfig"

Configure the code signing

In Xcode, code signing is set up in following places.

  • Signing & Capabilities tab of each build targets.
  • Signing of Build Settings tab.

Signing & Capabilities tab

The Signing & Capabilities tab for each target sets target-specific code signing settings. The values set in this tab are also set in the Signing of the target’s Build Settings.

Signing & Capabilities tab
Signing & Capabilities tab

The configuration items are grouped under Signing.

Setting itemsDescription
Automatically manage signingWhether the signing settings is managed by Xcode or not.
TeamThe developer team
Bundle IdentifierThe bundler identifier of target
Provisioning ProfileThe provisioning profile of target
Signing CertificateThe code signing certificate
Settings items

Build Settings tab

The Signing of the Build Settings tab contains code signing related settings, and the Signing & Capabilities and the Build Settings tabs are synchronized. Signing & Capabilities tab is synchronized with the Build Settings tab.

Signing & Capabilities tab is not available in the project settings but Build Settings tab is also available in the project settings.

We usually configure it in the Build Settings tab in the project tab but not in the target settings. Because the all targets in the project uses same code signing settings.

Signing in the Build Settings tab
Signing in the Build Settings tab

The settings related to the code signing are following.

Setting itemsDescription
Code Signing IdentityThe code signing certificate
Code Signing StyleWhether the settings are managed by Xcode or not
Development TeamThe developer team
Provisioning ProfileThe provisioning profile
Signing Settings of Build Settings tab

Clear the signing settings of the project file

Before changing code signing settings in the build settings file, clear the values set in the project file. Xcode will give priority to the project file settings if they are written in both the project file and the build settings file.

Do as follows.

STEP
Check the following settings in “Signing” in the “Build Settings” tab of the project settings to see if any of them are in bold.
  • Code Signing Identity
  • Development Team
  • Code Signing Style
  • Provisioning Profile
STEP
Select the item in bold and press the Delete key.

Items in bold are items that have been changed from the inherited values or the default values, and the settings are cleared by using the Delete key.

STEP
Do same operation for the target settings.

Edit the build settings file

Edit Signing.xcconfig to configure code signing. There are four items to configure.

  • CODE_SIGN_STYLE
  • DEVELOPMENT_TEAM
  • CODE_SIGN_IDENTITY
  • PROVISIONING_PROFILE_SPECIFIER

CODE_SIGN_STYLE

CODE_SIGN_STYLE specifis that whether the Xcode manage the code signing settings or not. The following values are defined.

ValueDescription
AutomaticTurn on Automatically manage signing.
ManualTurn off Automatically manage signing.
The value of CODE_SIGN_STYLE

DEVELOPMENT_TEAM

DEVELOPMENT_TEAM specifis the development team. The value is a team ID. The team ID is displayed at TEAM ID in Membership Details page in the Apple Developer web site.

CODE_SIGN_IDENTITY

CODE_SIGN_IDENTITY specifies the code signing certificate to sign. The value is a certificate name which is displayed in Xcode. For example, Automatic setting is Apple Development. Specify the the name is containing the team ID like Developer ID Application: Akira Hayashi (XXXXXXXX) in the keychain. Replace the (XXXXXXXX) with your team ID.

PROVISIONING_PROFILE_SPECIFIER

PROVISIONING_PROFILE_SPECIFIER specify the provisioning profile file. The value is name or UUID.

Example of the sample configuration settings file

The following code is a sample of Signing.xcconfig.

CODE_SIGN_STYLE = Automatic
DEVELOPMENT_TEAM = ABCDEFGHIJ
CODE_SIGN_IDENTITY = Apple Development
PROVISIONING_PROFILE_SPECIFIER = ExampleProfile

Remove from git management

Signing.xcconfig is used for not containing the code signing settings in the project file will be deployed, so remove the Signing.xcconfig from the git magement. To avoid build failer when the Signing.xcconfig is missing, use #include? statement to include it in the Debug.xcconfig and Release.xcconfig.

Let's share this post !

Author of this article

Akira Hayashiのアバター Akira Hayashi Representative, Software Engineer

I am an application developer loves programming. This blog is a tech blog, its articles are learning notes. In my work, I mainly focus on desktop and mobile application development, but I also write technical books and teach seminars. The websites of my work and books are here -> RK Kaihatsu.

TOC