Config different Capabilities based on environment
Hi is there a way to config Different Capabilities base on environment (Dev, Stagging, Production) (in my case is AppGroup) ?
Seem we should modify
plists:
"NatriumExampleProject/Info.plist":
CFBundleDisplayName:
Staging: App_staging
Production: App
"NatriumExampleProject/App.entitlements":
"aps-environment":
"*":
Debug: "development"
Release: "production"
But what is the config for other capabilities? (AppGroup for example)?
You could use xcconfig variables in your entitlements file, for instance:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>$(APPGROUP1)</string>
<string>$(APPGROUP2)</string>
</array>
</dict>
</plist>
and then use this in .natrium.yml
xcconfig:
APPGROUP1: "com.app.group1"
APPGROUP2: "com.app.group2"
or create different entitlement files per configuration / environment and use the files setting in your .natrium.yml file
Thanks. How about extension entitlement? (PushNotificationExtension.entitlements) (in extension we also have entitlement). can we still use xcconfig?
@vinhlk: Yes, works the same way
I have tried NotificationExtension. the 1st option xcconfig does not seem to work. (Also created scheme for pushnotification-dev, pushnotification-staging...)
Another approach would be to use the files setting in your .natrium.yml file:
files:
Path/To/NotificationExtensions.entitlements:
Staging: Path/To/NotificationExtensions-staging.entitlements:
Production: Path/To/NotificationExtensions-production.entitlements:
The only thing you need to do is create 2 seperate entitlements files for each environment
I still have problem config natrium with notification extension. I have set value for notification extension 's info.plist (with bundle ID and Display name ) for different environment and successfully generate Bundle Identifier for notification extension. But in my build setting (for notification extension target, the Product Bundle Identifier value never change. Do you have a sample natrium that use notification extension for different environment?
Hi @basvankuijck I made it work by using multiple file for notification extension entitlement. i have tried xcconfig and "RichPushNotificationExtension/NotificationExtension.entitlements": "com.apple.security.application-groups": "#{AppGroup}" but no luck. Hope there is an update support these config instead of multiple file
The "problem" is that it only changes the xcconfig for the target that initiates the build (e.g. NatriumExampleProject) and not any target dependencies (e.g. RichPushNotificationExtension).
I'll put it on the todo list so you can change the settings of any dependency target