Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Per configuration app group entitlement strings in Xcode?

Tags:

Is there an easy way to have per-configuration app group entitlement strings in Xcode projects?

We're trying to share settings between an iOS application and today extension using an "app group" entitlement in both the targets.

The problem we're having is that we build the application with different bundle and team ids depending on whether it's an enterprise or a release build.

When I use Xcode 6's Capabilities screen, the app groups show up in red lettering and I don't see a way to change the strings for each configuration individually.

I assume one of the following will work, but I don't know which I should try first:

  1. .xcconfig files
  2. Manually created entitlement files
  3. Build script
  4. Configuration-dependent plist entries

Suggestions?

like image 962
EricS Avatar asked Aug 30 '14 20:08

EricS


People also ask

What is entitlements file in Xcode?

An app stores its entitlements as key-value pairs embedded in the code signature of its binary executable. You configure entitlements for your app by declaring capabilities for a target in Xcode. Xcode records capabilities that you add in a property list file with the . entitlements extension.


1 Answers

You can use a different entitlements file for each configuration. This can be specified in the Xcode "Build Settings" user interface, or done through build configuration files (.xcconfig).

Example xcconfig:

CODE_SIGN_ENTITLEMENTS = Debug.entitlements

Where the value for CODE_SIGN_ENTITLEMENTS points to the correct entitlements file for this configuration. You can create as many configurations as you want in Xcode. By default Xcode creates Debug and Release, you may add Enterprise and use a build configuration file which points CODE_SIGN_ENTITLEMENTS to the correct entitlements file for Enterprise builds.

The Xcode "Capabilities" user interface will create and manage an entitlements file that is named after your build product. You can edit this file directly if you desire.

  1. Create an XCConfig build configuration file for each of your build configurations. For this example we will just use Debug and Release, it's simple to add your own build configurations such as Enterprise.
  2. As described above, populate the xcconfig files with the appropriate CODE_SIGN_ENTITLEMENTS settings.
  3. In the Project "Info" user interface, set the build configuration to use the appropriate XCConfig file:

enter image description here

  1. You can confirm by looking at the Code Signing Entitlements build setting for your build product. You should see something like this:

enter image description here

If you see bold text there, highlight that build setting and hit delete. This will remove the Xcode build setting that is overriding your xcconfig setting.

like image 76
quellish Avatar answered Sep 27 '22 22:09

quellish