3

I have two different targets, and I try to get two different groups to each targets. My goal is to have two different versions, one for the App Store, one for distribution. I installed the push notification that worked well until now for the Company version, but, as I created the enterprise provisionning, xcode refuse to put different groups for this two targets (in the Capabilities/App Groups section)

Target Enterprise: Target Enterprise enter image description here
Target Company (for Apple Store)
Target Company (App Store) enter image description here

How to get this two targets with two different groups? (Xcode change me automatically for the target GMP_app_ios, if I change the group of the target GMP_app_ios AppStore and vice versa).

Cœur
  • 37,241
  • 25
  • 195
  • 267
ΩlostA
  • 2,501
  • 5
  • 27
  • 63
  • 1
    What are the values for the **Code Signing Entitlements** (under Build Settings) for each target? – Bojan Dimovski May 02 '19 at 18:02
  • 1
    When building an app for multiple environments, I'd suggest configuring it using `.xcconfig`s instead of creating multiple targets. Try checking out this post https://thoughtbot.com/blog/let-s-setup-your-ios-environments. – Bojan Dimovski May 02 '19 at 18:06
  • @BojanDimovski Good point, it is exaclty the same for both : GMP_app_ios/GMP_app_ios.entitlements Is it the source of the problem? – ΩlostA May 02 '19 at 18:24
  • 1
    Yes, you have two options, the first is a quick fix and would be to create a duplicate file and set it in the build settings. The other one, which needs a bit more work, but is better on the long run, is to migrate to `xcconfig`s. – Bojan Dimovski May 02 '19 at 18:30
  • 1
    @BojanDimovski Thank you for you answer, I will do it for now the quick solution, but I will put the second one for the long term. – ΩlostA May 02 '19 at 18:34
  • I'll put it as an answer since it ultimately solves the problem. – Bojan Dimovski May 02 '19 at 18:36
  • 1
    Yep, I will validate it, I just did it, It works perfectly. I would never find this without your advice :D – ΩlostA May 02 '19 at 18:38

1 Answers1

12

Since you have a duplicated target, the issue is that the second target uses the same entitlements file as the original one (check the official documentation for more info).

You can do a quick fix, which would be to duplicate the entitlements file and update the Code Signing Entitlements (CODE_SIGN_ENTITLEMENTS) value under Build Settings.

A long term solution would be to migrate the project to using xcconfig files, having a single target with different configuration pairs (Debug and Release) for each environment (Enterprise and Company in your case). A good starting point would be the Let's Set Up Your iOS Environments blog post.

Also, note that the values in the entitlement files must correspond to the values in the App ID configuration on the developer portal.

Bojan Dimovski
  • 1,216
  • 11
  • 25