expo: Bare workflow: Constants.manifest is null in standalone version of app?

🐛 Bug Report

Environment

Expo CLI 3.17.16 environment info: System: OS: macOS 10.15.3 Shell: 5.7.1 - /bin/zsh Binaries: Node: 13.4.0 - ~/.nvm/versions/node/v13.4.0/bin/node Yarn: 1.21.1 - /usr/local/bin/yarn npm: 6.13.4 - ~/.nvm/versions/node/v13.4.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman IDEs: Xcode: 11.4/11E146 - /usr/bin/xcodebuild npmPackages: expo: ^37.0.2 => 37.0.4 react: ~16.9.0 => 16.9.0 react-native: ~0.61.4 => 0.61.5 react-navigation: ^3.11.0 => 3.11.1 npmGlobalPackages: expo-cli: 3.17.16

Bare workflow

Steps to Reproduce

Constants.manifest is null, even in a bundled app created with expo publish.

Expected Behavior

In bare workflow, just like the managed workflow, I’d expect to be able to access the manifest in the released/standalone version of the app. Specifically, I need to access to the revisionId so that I can use @sentry/react-native properly, as that package uses the revisionId for sourcemaps and such.

I don’t think it should be too tough to access the manifest, as it’s sitting right there in the app.manifest file!

Actual Behavior

Constants.manifest is null.

Reproducible Demo

In a standalone, bare workflow app:

import Constants from 'expo-constants';
console.log(Constants.manifest)

Prints out null.

Thanks in advance!

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 17
  • Comments: 34 (15 by maintainers)

Most upvoted comments

Agreed to @lc3t35, looks like various expo packages use Constants.manifest with no fallback to Updates.manifest:

All packages README says it support bare project, but without the Constants.manifest they will not work correctly when deployed in production with no clear error why it failed.

I was using the expo-firebase-core with expo-firebase-recaptcha and used FirebaseCore. DEFAULT_WEB_APP_OPTIONS to provide values for <FirebaseRecaptchaVerifierModal firebaseConfig={...} /> and it did not works in production, needed t change to { ...FirebaseCore.DEFAULT_APP_OPTIONS, authDomain: '<url>.firebaseapp.com' }.

Hey there! You should be able to use Updates.manifest for this instead.

i’m reopening this because we are investigating approaches we can take to smooth over this difference.

@doylemark - just stop using Constants.manifest in your app when you eject

@lc3t35 - expo-constants is supported in bare workflow but only for a subset of properties - i made an issue for us to clarify this in docs https://github.com/expo/expo/issues/7890.

we may end up deprecating manifest from Constants in the next SDK - it makes more sense for it to live on expo-updates.

Updates.manifest.releaseChannel

it only doesn’t return the releaseChannel when in development because manifest is blank in development

@esamelson - If I use Updates.releaseChannel I get: TypeError: undefined is not an object (evaluating '_expoUpdates.default.releaseChannel') "expo-constants": "~9.3.3", "expo-updates": "~0.4.1",

@christopherdro - expo-constants@9.3.0 and newer makes Constants.manifest itself fall back to Updates.manifest if it’s available – https://github.com/expo/expo/blob/0e08d74db9b1808e2d650d5bfc847ba744f6f118/packages/expo-constants/src/Constants.ts#L36-L37 – so updating to that version should fix the issues noted in https://github.com/expo/expo/issues/7721#issuecomment-619624914, as well as the expo-asset issue you mentioned, provided expo-updates is installed.

@bydecker - you can use Updates.releaseChannel instead and bypass the manifest entirely – Updates.releaseChannel is guaranteed to always be defined and nonempty since it exposes the native build property, whereas Constants.manifest.releaseChannel depends entirely on the manifest logic/format.

Is there any workaround to solve this? Yes I got the idea that it doesn’t work, the same for me, Constants.manifest is null when you execute the app with: react-native run-android or react-native run-ios. Is there any solution that work for expo managed and bare workflow? I was following this: https://docs.expo.io/guides/environment-variables/ but sadly it doesn’t work as expected! That’s a shame because there is no information about this in the documentation either.

To add to this list, sentry-expo relies on Constants.manifest.

Woah, thanks @esamelson! 🙏Did not think to look there…

@jonathanstiansen it’s not set locally (same as in Managed apps) but is set in the released/standalone version of you app

@esamelson Thank you for your reply. Currently using expo-constants@9.2.0and expo-updates@0.3.5 on SDK 39. I will try and update those deps this week and test again.

good point, it appears to not be explicitly defined on that type. you should still be able to use it without a typeerror due to [key: string]: any; but i’ve opened a pr to add it to the type explicitly: https://github.com/expo/expo/pull/7875