How to access Constants.manifest.releaseChannel in bare workflow?

Please provide the following:

  1. SDK Version: 40
  2. Platforms(Android/iOS/web/all): Android/iOS
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

I have been using the managed workflow for a while now, and just started working on ejecting to bare workflow so that I can incorporate the InAppPurchase module. I am using release channels to help manage environment variables like so:

let channel = Constants.manifest?.releaseChannel || '';
if (channel.indexOf('prod') !== -1) {
  channel = 'prod';
}
else if (channel.indexOf('test') !== -1) {
  channel = 'test';
}
else {
  channel = "dev";
}

After ejecting, in xcode I have set the Supporting/Expo.plist value

EXUpdatesReleaseChannel => 'test'

And in Android Studio I have set the AndroidManifest.xml value

<meta-data android:name="expo.modules.updates.EXPO_RELEASE_CHANNEL" android:value="test" />

When I run the app in in release variant mode (I’ve tried from my device connected to my local machine, as well as from Apple TestFlight and Google Internal Test track) the Constants.manifest does not contain any releaseChannel.

Is this supposed to work in bare workflow? If not, what’s the accepted practice for managing environment variables in bare workflow while also supporting OTA updates?

After some more testing, I found the order of events between app install and publish is making a difference.
First I run publish

expo publish --release-channel test --target bare

then I use xcode and use Run action with my device connected (Build Configuration: Release), and the Constants.manifest.releaseChannel is empty. However, if I publish again with the exact same command, kill the app and open again on the device then the release channel is correct and the published update is picked up. It’s like the published update doesn’t get picked up until I run expo publish only after the app is installed. I can repeat this process and get the same results. I can also repeat this process by installing the app from TestFlight instead of xcode and I am getting the same results: release channel in the app is populated only if I run expo publish AFTER app is installed on my device. I’m confused why this would be this way - maybe something to do with the way the app is being cached?

So the next thing I tried was to Delete the app first before trying to install from TestFlight. Note that the release channel has already been published to multiple times now. After deleting the app and data from the device, I installed the app fresh from TestFlight, and the correct published app version comes up indicating the release channel is working correctly the first time.

I guess as long as a fresh install works with the latest published update I’m OK with this now, but still a little concerned about this all working in production. If anyone can help me understand why I might be seeing the behavior above then maybe it will make me feel better. Thanks in advance for any insight anyone may have.

Updates.releaseChannel: Updates - Expo Documentation

the reason you can’t access update-related properties on manifest on the initial build is that there is no update on the initial build – it’s just an embedded js bundle with some of the app config. (you can see what will be embedded if you run expo config --public). this is confusing and we’re working towards clarifying this in an upcoming sdk.

Thanks @notbrent. I think I assumed that even though there is no update in the initial build, the updates library would still run on first launch and apply the latest applicable published update before the user sees the app (while also populating the manifest’s update-related properties)? If I can’t count on the Constants.manifest.releaseChannel being present in the initial launch to set my environment variables, is it advisable to change my code to default to ‘prod’ release channel when I am building for production?

let channel = Constants.manifest?.releaseChannel || 'prod';

FYI here’s my Expo.plist

I’m sorry, I just realized you were saying I should use Updates.releaseChannel instead of Constants.manifest.releaseChannel. I’ll try that and let you know!

1 Like

Updates.releaseChannel works great!

let channel = Updates.releaseChannel || '';
if (channel.indexOf('prod') !== -1) {
  channel = 'prod';
}
else if (channel.indexOf('test') !== -1) {
  channel = 'test';
}
else {
  channel = "dev";
}

Probably the documentation on this page below needs to be updated to mention Updates.releaseChannel, as that’s where I got the code pattern originally for using Constants.manifest.releaseChannel to control environment variables.
https://docs.expo.io/distribution/release-channels/#using-release-channels-for-environment-variable-configuration

1 Like

thanks for pointing that out! i’ll update it