Entitlements / Capabilities per Xcode scheme
You can achieve the desired behaviour by using a different build configuration.
- Copy the entitlements file and adjust it to your needs, e.g, remove the Apple Pay entitlement for enterprise distribution
- Select the project on the project settings view
- Add a new build configuration, e.g., AppStore
- Switch to your app target and adjust the value for the new build configuration.
- Create a new scheme, e.g., AppStore and select the new build configuration in the "Archive" Section of the scheme settings
In general, it is a good idea to have separate schemes and build configurations. That way you can support several different build configurations depending on your needs, e.g., Enterprise distribution, Hockey Testing, App Store etc. .
If you want to make your project setup more maintainable consider using xcconfig files to organize your build settings.
A possible approach:
- Put your different schemes' entitlements files in a folder
- Have your project or target's Build Settings > Code Signing Entitlements point to a location such as
$(PROJECT_DIR)/AppName/AppName.entitlements
- In Edit Scheme > Build > Pre-actions, add a "Run Script" action to copy the entitlements file for that scheme, to the location you specified in step 2. e.g.
cp ${PROJECT_DIR}/entitlements/DevScheme.entitlements ${PROJECT_DIR}/AppName/AppName.entitlements