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

Config is empty after upgrade to RN 0.71 #777

Closed
gimi-anders opened this issue Sep 27, 2023 · 32 comments
Closed

Config is empty after upgrade to RN 0.71 #777

gimi-anders opened this issue Sep 27, 2023 · 32 comments

Comments

@gimi-anders
Copy link

gimi-anders commented Sep 27, 2023

react-native: 0.71.13
react-native-config: 1.5.1

After upgrading react-native from 0.70.9 to 0.71.13, the config is empty.

This is what I get when I log config:

import Config from "react-native-config";
console.log(Config);

Output:
{"dependencies": {}}

I have tried downgrading to version 1.4 and 1.3, but that does not help.

I have set this in the pre-actions without success:

cp "${PROJECT_DIR}/../.env.staging" "${PROJECT_DIR}/../.env"
echo “.env.staging” > /tmp/envfile
touch "${PROJECT_DIR}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildDotenvConfig.rb"

Note that it worked fine on RN 0.70.9.
Any help would be appreciated.

Update: I am having the exact same issue on Android

@cal-overflow
Copy link

Facing the same issue with RN 0.72.5. Though the console.log(Config) results in {}`.

@kulak91
Copy link

kulak91 commented Sep 29, 2023

Anticipating you are using expo. Launch it with EXPO_NO_DOTENV=1

@gimi-anders
Copy link
Author

Anticipating you are using expo. Launch it with EXPO_NO_DOTENV=1

@kulak91 No, I am not using expo.

@zabojad
Copy link

zabojad commented Oct 3, 2023

I'm having the same issue with RN 0.72.5 (new arch not enabled). Has anyone found some solution or workaround ?

@RamanSB
Copy link

RamanSB commented Oct 3, 2023

Same issue I'm running it with Expo & @kulak91 suggestion did not work.

@kiwioz
Copy link

kiwioz commented Oct 9, 2023

I upgrade to RN 0.71.13 and then upgraded react-native-config from 1.4.6 to 1.5.1 at this point iOS Config became empty.

Downgrade react-native-config back to 1.4.6 and it started working again, Config was being returned as expected.

@vanenshi
Copy link

the same problem is happening in the android

@Sahil6458
Copy link

#541 (comment)

@vanenshi
Copy link

#541 (comment)
I simply give permission to node_modules of read/write/execute . sudo chmod -R 777 node_modules/*

This hack gives us the idea that probably one of the files in the library doesn't have the correct permission. and seems like this is going to be related to Mac/Unix.
@Sahil6458 but giving access to all the files in the node_modules is not a good idea, first of all we cannot force all our team members to use this method, and second, this is extremely dangerous
I'll try to check which file lacks the permission and publish a patch

@vanenshi
Copy link

@gimi-anders can you please tell us your OS and xcode version?

@gimi-anders
Copy link
Author

@vanenshi When I tried this the last time I was on OS 13 and xcode 14.
I have now upgraded my OS and xcode, but I have not checked if that changes anything.

@vanenshi
Copy link

@gimi-anders i am using the xcode 15 and the same problem is happening, so its not related to the xcode version

@tuanduc2904
Copy link

tuanduc2904 commented Oct 13, 2023

the same problem is happening in the android. NativeModules.ReactNativeConfigModule it's null

@DonBrowny
Copy link

I having the same in my app.
Xcode Version: 15
react-native: 0.72.5

@jeremy303
Copy link

jeremy303 commented Oct 19, 2023

+1
Xcode 14.3.1
react-native 0.72.5
react-native-config 1.5.1

Like @kiwioz, downgrading to 1.4.6 restored function.

@esenbi
Copy link

esenbi commented Oct 20, 2023

had same problem, turns out i missed this step in config https://github.com/luggit/react-native-config#app-extensions

@waseemawan
Copy link

waseemawan commented Oct 25, 2023

Struggling with same issue from past two weeks, my error is in iOS build with error message "ReactNativeConfig.h" not found. Anyone got a real solution?
Xcode 15
react-native 0.72.5
react-native-config 1.5.1 where the internal library name has changed to RNCConfig.h, (also tried 1.4.12 with old header file name ReactNativeConfig.h)

@DonBrowny
Copy link

DonBrowny commented Oct 26, 2023

I having the same in my app. Xcode Version: 15 react-native: 0.72.5

This was an issue with the nx monorepo. After updating nx version the issue got resolved.

@gimi-anders
Copy link
Author

@vanenshi Any progress on this?

@vanenshi
Copy link

@vanenshi Any progress on this?

@gimi-anders sorry I caught up in some business related stuff and couldn't work on this. 🫠
My workaround was to detect the build type ("betaRelease" for example) and load the corresponding env manually (as a json file)
Since our app don't need any native .env configuration, this solution was enough. 👌
Unfortunately, I won't be able to work on this issue. 🥲

@gimi-anders gimi-anders changed the title Config is empty on iOS after upgrade to RN 0.71 Config is empty after upgrade to RN 0.71 Dec 20, 2023
@gimi-anders
Copy link
Author

Has anyone got this library working on RN 0.71 or 0.72?

@DonBrowny
Copy link

Has anyone got this library working on RN 0.71 or 0.72?

Yes, i Have. I suspect the .env file location might be the issue for you. After the RN i need to change my ENVFILES location in the podfile

PS: I am using NX monorepo so my location of .env might look different from yours.

  ENVFILES = {
    'Debug' => '$(PODS_ROOT)/../../.env',
    'Release' => '$(PODS_ROOT)/../../.env',
  }

@gimi-anders
Copy link
Author

Has anyone got this library working on RN 0.71 or 0.72?

Yes, i Have. I suspect the .env file location might be the issue for you. After the RN i need to change my ENVFILES location in the podfile

PS: I am using NX monorepo so my location of .env might look different from yours.

  ENVFILES = {
    'Debug' => '$(PODS_ROOT)/../../.env',
    'Release' => '$(PODS_ROOT)/../../.env',
  }

I will test this, but unfortunately this is not the complete solution, since I experience the same issue on both iOS and Android. Your suggestion only applies to iOS.

@gimi-anders
Copy link
Author

Ok folks, it seems like this was completely an issue due to a silly mistake on my side. I will post it here, maybe someone has done the same mistake.

I had named the react-native config file incorrectly to react-native-config.js.
After giving it the correct name react-native.config.js, the config works fine on both iOS and Android.

Case closed.

@PortugalNeto
Copy link

Ok folks, it seems like this was completely an issue due to a silly mistake on my side. I will post it here, maybe someone has done the same mistake.

I had named the react-native config file incorrectly to react-native-config.js. After giving it the correct name react-native.config.js, the config works fine on both iOS and Android.

Case closed.

But why have you closed this issue if a bunch of people is facing the same problem?
In my case it's on both, iOS and android.

@luizeduul
Copy link

The same here

@Roasted-Peanut
Copy link

i had the same problem, can someone help me.
#792

@maharjanrajans
Copy link

This worked for me!
#770 (comment)
ensure that you add your BuildConfig to your proguard rules. Took me hours to figure out. IMHO the README needs a major makeover. This should be pretty much on top it.

In your proguard-rules.pro add

-keep class my.app.package.BuildConfig { *; }

Note
Obviously you need to adapt the package to your actual app package name (my.app.package)

@Roasted-Peanut
Copy link

Roasted-Peanut commented Mar 8, 2024

Screenshot 2024-03-08 at 17 47 32

Điều này đã hiệu quả với tôi! #770 (nhận xét) đảm bảo rằng bạn thêm BuildConfig vào quy tắc bảo vệ của mình. Tôi đã mất hàng giờ để tìm ra. IMHO README cần một sự thay đổi lớn. Điều này sẽ được khá nhiều trên đầu nó.

Trong proguard-rules.pro của bạn thêm

-keep class my.app.package.BuildConfig { *; }

Lưu ý Rõ ràng là bạn cần điều chỉnh gói phù hợp với tên gói ứng dụng thực tế của mình ( my.app.package )

it not work for me. Please help me!
"react-native": "0.73.2",
"react-native-config": "^1.5.1",

@hieulamblackbird
Copy link

work perfect on Xcode version 15.3
react-native-config , version 1.5.1
react-native , version 0.73.6

@rithikronald
Copy link

rithikronald commented Jun 12, 2024

If the config is returning undefined in IOS try this, it worked for me
"react-native": "^0.71.0",
"react-native-config": "1.4.6",

For IOS:
Add this line to the top of the pod file
pod 'react-native-config', :path => '../node_modules/react-native-config'

@vuquangit
Copy link

If the config is returning undefined in IOS try this, it worked for me "react-native": "^0.71.0", "react-native-config": "1.4.6",

For IOS: Add this line to the top of the pod file pod 'react-native-config', :path => '../node_modules/react-native-config'

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests