Conditionals in an Entitlements file by platform?

(Sometimes I think I'm the only person who's actually using the new Xcode multiplatform app paradigm! So hard finding info on the various "gotchas".)

My multiplatform app supports macOS (not Catalyst), iOS, iPadOS, and tvOS. It's an internal testing app, never meant to be on any app store.

It has only one Target (the new multiplatform target).

I've been able to work through all the teething issues except for Entitlements. My iOS and tvOS app both use 3 entitlements that are for those platforms only. The macOS version doesn't need or want them. But if those 3 entitlements are in the .entitlements file, the macOS version won't launch at all (not even in the sim).

Of course as soon as I take those 3 entitlements out of the file, it runs.

Sooo...in a multiplatform targeted app how do you specify different entitlements for different platforms? Or is it not possible?

Thanks!

Answered by DTS Engineer in 748853022

It depends:

  • If an entitlement value changes, you can set the entitlement based on a build setting and then conditionalise that build setting.

  • If you need to add or remove whole entitlements, I think the best option is to have two .entitlements files and then conditionalise the Code Signing Entitlements (CODE_SIGN_ENTITLEMENTS) build setting to point to the right file.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

It depends:

  • If an entitlement value changes, you can set the entitlement based on a build setting and then conditionalise that build setting.

  • If you need to add or remove whole entitlements, I think the best option is to have two .entitlements files and then conditionalise the Code Signing Entitlements (CODE_SIGN_ENTITLEMENTS) build setting to point to the right file.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

In addition to the correct answer of Quinn above. To conditionalise the entitlements based on platform, navigate to the xcode build settings, search for 'entitlements', and add an entry for a platform specific entitlements file, as in the example below:

Conditionals in an Entitlements file by platform?
 
 
Q