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)
Agreed to @lc3t35, looks like various expo packages use
Constants.manifestwith no fallback toUpdates.manifest:expo-auth-session: https://github.com/expo/expo/blob/eac76cb628dcb019b64f5ed607c0a4818eba05a8/packages/expo-auth-session/src/ManagedSessionUrlProvider.tsexpo-notification: https://github.com/expo/expo/blob/8cd116e5e0ac120e6f14dd09a4563a7018adffb8/packages/expo-notifications/src/getDevicePushTokenAsync.web.tsexpo-asset: https://github.com/expo/expo/blob/52c9b2540ccf290d5bf42cf0f2cc0b680eed6e1e/packages/expo-asset/src/PlatformUtils.tsexpo-linking: https://github.com/expo/expo/blob/f60b83a3f353f4a7fe2bc9df80d3da8f90bcd331/packages/expo-linking/src/Linking.tsexpo-store-review: https://github.com/expo/expo/blob/92f6de58cfc369f1e4c0adee7c616e1e52bcc253/packages/expo-store-review/src/StoreReview.tsexpo-firebase-core: https://github.com/expo/expo/blob/776d46fa0cc8eda358730d144af6a7b59ac52a89/packages/expo-firebase-core/src/FirebaseOptions.tsexpo-firebase-analytics: https://github.com/expo/expo/blob/b9fac3f10f8c073da02e27a26730633186a4df24/packages/expo-firebase-analytics/src/ExpoFirebaseAnalytics.tsAll packages README says it support bare project, but without the
Constants.manifestthey will not work correctly when deployed in production with no clear error why it failed.I was using the
expo-firebase-corewithexpo-firebase-recaptchaand usedFirebaseCore. DEFAULT_WEB_APP_OPTIONSto 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.manifestin your app when you eject@lc3t35 -
expo-constantsis 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
manifestfromConstantsin the next SDK - it makes more sense for it to live onexpo-updates.Updates.manifest.releaseChannelit 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.0and newer makesConstants.manifestitself fall back toUpdates.manifestif 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 theexpo-assetissue you mentioned, provided expo-updates is installed.@bydecker - you can use
Updates.releaseChannelinstead and bypass the manifest entirely –Updates.releaseChannelis guaranteed to always be defined and nonempty since it exposes the native build property, whereasConstants.manifest.releaseChanneldepends 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-exporelies onConstants.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.0andexpo-updates@0.3.5on 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