Natrium icon indicating copy to clipboard operation
Natrium copied to clipboard

Config different Capabilities based on environment

Open vinhlk opened this issue 6 years ago • 8 comments

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)?

vinhlk avatar Mar 20 '19 14:03 vinhlk

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

basvankuijck avatar Mar 20 '19 14:03 basvankuijck

Thanks. How about extension entitlement? (PushNotificationExtension.entitlements) (in extension we also have entitlement). can we still use xcconfig?

vinhlk avatar Mar 20 '19 15:03 vinhlk

@vinhlk: Yes, works the same way

basvankuijck avatar Apr 01 '19 11:04 basvankuijck

I have tried NotificationExtension. the 1st option xcconfig does not seem to work. (Also created scheme for pushnotification-dev, pushnotification-staging...)

vinhlk avatar Apr 04 '19 17:04 vinhlk

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

basvankuijck avatar Apr 05 '19 11:04 basvankuijck

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?

vinhlk avatar Apr 06 '19 19:04 vinhlk

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

vinhlk avatar Apr 07 '19 13:04 vinhlk

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

basvankuijck avatar Apr 08 '19 07:04 basvankuijck