Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constants.manifest is broken and so is Constants.expoConfig #19762

Closed
DianaLaa opened this issue Oct 28, 2022 · 10 comments
Closed

Constants.manifest is broken and so is Constants.expoConfig #19762

DianaLaa opened this issue Oct 28, 2022 · 10 comments
Labels
Constants incomplete issue: missing or invalid repro A minimal reproducible example is required for most issues needs more info To be used when awaiting reporter response

Comments

@DianaLaa
Copy link

Summary

Constants.manifest?.version always returns undefined
Constants.manifest?.ios?.buildNumber always returns undefined
Constants.manifest?.android?.versionCode also always returns undefined

Replacing manifest with expoConfig does not work.
Please can someone tell me what the new way to do this is? I need it for debugging and support.

What platform(s) does this occur on?

Android

Environment

expo-env-info 1.0.5 environment info:
System:
OS: Windows 10 10.0.19044
Binaries:
Node: 16.17.0 - C:\Program Files\nodejs\node.EXE
Yarn: 3.2.0 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.15.0 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: AI-213.7172.25.2113.9123335
npmPackages:
@expo/metro-config: ^0.1.40 => 0.1.84
babel-preset-expo: 9.0.2 => 9.0.2
expo: ^44.0.0 => 44.0.6
react: 17.0.1 => 17.0.1
react-native: https://github.com/expo/react-native/archive/sdk-44.0.0.tar.gz => 0.64.3
react-navigation: ^4.4.0 => 4.4.4
Expo Workflow: managed

Minimal reproducible example

@DianaLaa DianaLaa added the needs validation Issue needs to be validated label Oct 28, 2022
@baochungit
Copy link

As mentioned in Expo Documentation, once Constants.manifest is null, the Constants.manifest2 will present.
You could check Constants.manifest2.extra.expoClient to see if it works.

@phryneas
Copy link

phryneas commented Nov 2, 2022

In case it helps someone, I did now end up with

function getExtra(constant: string) {
    for (const extra of [Constants.manifest?.extra, Constants.manifest2?.extra, Updates.manifest?.extra]) {
        const c = extra?.[constant] ?? extra?.expoClient?.extra?.[constant];
        if (c) return c;
    }
    throw new Error(`constant ${constant} not found in manifest.`);
}

So there are six possible places and I'm not sure which one is there when.

Constants.manifest.extra, Constants.manifest.extra.expoClient.extra, Constants.manifest2.extra, Constants.manifest2.extra.expoClient.extra, Updates.manifest.extra, Updates.manifest.extra.expoClient.extra,

@Simek Simek added the Constants label Nov 8, 2022
@brentvatne
Copy link
Member

brentvatne commented Nov 26, 2022

can someone share a reproducible example that demonstrates the issue with Constants.expoConfig? and on sdk 47?

@brentvatne brentvatne added needs more info To be used when awaiting reporter response incomplete issue: missing or invalid repro A minimal reproducible example is required for most issues and removed needs validation Issue needs to be validated labels Nov 26, 2022
@expo-bot
Copy link
Collaborator

Hi there! It looks like your issue requires a minimal reproducible example, but it is invalid or absent. Please prepare such an example and share it in a new issue.

The best way to get attention to your issue is to provide a clean and easy way for a developer to reproduce the issue on their own machine. Please do not provide your entire project, or a project with more code than is necessary to reproduce the issue.

A side benefit of going through the process of narrowing down the minimal amount of code needed to reproduce the issue is that you may get lucky and discover that the bug is due to a mistake in your application code that you can quickly fix on your own.

Resources

Common concerns

"I've only been able to reproduce it in private, proprietary code"

You may not have spent enough time narrowing down the root cause of the issue. Try out the techniques discussed in this manual debugging guide to learn how to isolate the problem from the rest of your codebase.

"I didn't have time to create one"

That's understandable, it can take some time to prepare. We ask that you hold off on filing an issue until you are able to fully complete the required fields in the issue template.

"You can reproduce it by yourself by creating a project and following these steps"

This is useful knowledge, but it's still valuable to have the resulting project that is produced from running the steps, where you have verified you can reproduce the issue.

@ide
Copy link
Member

ide commented Nov 26, 2022

Constants.expoConfig was introduced to replace almost all the use cases of Constants.manifest and remove the need to try to switch between accessing Constants.manifest and Constants.manifest2, obviously no one wants to have to discern between those two APIs. The manifest and manifest2 properties aren't formally deprecated yet but treat them as softly deprecated in favor of expoConfig.

The original post mentioned using Expo SDK 44. Constants.expoConfig was introduced in SDK 46. Like Brent suggested above, try upgrading to SDK 47 (or perhaps an easier path is to make a new test project with npx expo init just to try things out) and using Constants.expoConfig.

@events-jonas-chrisw
Copy link

This doesn't work at all on Metro web

@ide
Copy link
Member

ide commented Aug 29, 2023

@events-jonas-chrisw Could you please be more precise?

@events-jonas-chrisw
Copy link

@events-jonas-chrisw Could you please be more precise?

When i use expo constants on android or IOS, Constants.expoConfig has a complete object.
If I build using metro for web, the object is empty

@ide
Copy link
Member

ide commented Aug 31, 2023

@events-jonas-chrisw Thank you. I'll take a look when I have some time. If investigating this in a timely manner is important to you I recommend having a look at the code and seeing if you can't figure out what the cause is / what's going on.

@ide
Copy link
Member

ide commented Oct 12, 2023

@events-jonas-chrisw Constants.expoConfig on web for SDK 49 requires the Expo Router Babel plugin. In SDK 50+ (upcoming), the Expo (not Expo Router) Babel plugin will have support for Constants.expoConfig built in.

Related issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Constants incomplete issue: missing or invalid repro A minimal reproducible example is required for most issues needs more info To be used when awaiting reporter response
Projects
None yet
Development

No branches or pull requests

8 participants