I use expo-constants as described here: Environment variables in Expo - Expo Documentation.
I expected Constants.manifest2.extra.apiUrl to be http://localhost:3000/api, however, I cannot find any trace of apiUrl in all of the manifest2 object.
I did read all the documentation but did not find anything related.
Did I miss something?
Expos choice of having variables on Constants.manifest2 in some cases, Constants.manifest in some cases and also introduce Updates.manifest that works in some cases without clear documentation is sub-optimal to say the least and cause a lot of headaches and cursing It also breaks libraries like bugsnag as they expect Constants.manifest to exist, but does not in some cases when using EAS channels.
It should be a pretty darn straightforward job to provide a unified API or interface/library for getting these values if it only was properly documented, why it is not already unified from expos side is unclear to me.
What is the suggested bulletproof way of getting the SDK version and the “extra” section from the manifest?
Ah, I thought your issue was when using a project you had published with EAS update, but it sounds like you’re just trying to access them locally?
Either way, there is documentation here Using environment variables with EAS Update - Expo Documentation on accessing env variables. It appears they live under Constants.manifest2?.extra?.expoClient?.extra
Thanks for your reply, I don’t want to publish any update for now. I have a .app created using EAS Build which is a development build. I use expo start --dev-client to start the metro bundler (which is why I expect the variable to be http://localhost:3000/api).
I did read the entire documentation but I did not find anything related to my problem.
I tried accessing Constants.manifest2?.extra?.expoClient?.extra but it is undefined.
I also have another problem which only occurs when adding the extra key in app.config.js and trying to select my development server in the servers list, I get the following error:
I do not have this problem after removing the extra key, selecting my development server and re-adding the extra key and hot reloading.
Thanks
EDIT: Found the problem, my extra object did not contain any eas object. This was only described in the Using environment variables with EAS Update documentation but nowhere else.
Like @kennethlynne said, I would prefer having one nice interface where I could store and manage my environment variables using EAS services. It’s kind of a pain to know exactly what to do at each stage of delivery with the current way of handling them, but I guess that’s mostly due to the transition being made to everything EAS.
Anyway, thank you so much for the replies, have a nice day!
Regarding the projectId issue we also started seeing that, and from debugging and reading source code we managed to figure out a workaround: Add this under the extra field
eas: { projectId: '<found in expo.dev under project overview>' }, // undocumented property that expo-cli seems to require to determine how to set up expo-updates https://github.com/expo/expo-cli/pull/3890/files#diff-663d514e69e821be5315a630820a5f710de0fba6d686012702292d3aecf0cf23