lugg / react-native-config

Bring some 12 factor love to your mobile apps!
MIT License
4.82k stars 657 forks source link

IOS Info.plist not reading the variables #645

Closed MosefAsad closed 2 years ago

MosefAsad commented 2 years ago

Dependency versions: React Native: 0.64.2 React Native Config: 1.4.5

I'm using RNC to help with changing the deployment keys for CodePush. I've followed the instructions in the Read.me and after checking my tmp.xcconfig I can see the environment variables are correct.

I've also added the following to the "Pre-actions" for "Build" and "Run":

cp "${PROJECT_DIR}/../.env.development" "${PROJECT_DIR}/../.env"
"${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb" "${SRCROOT}/.." "${SRCROOT}/tmp.xcconfig"

The "Provide build settings from" drop down menu has the Target as the selection and is not empty.

When I run the project I'm getting an error saying the deployment key is invalid. This error goes away and the update from Codepush is downloaded without issue when i paste the key as is in the Info.plist instead of using $(PUSH_KEY) as the value.

What am I doing wrong? Has anyone else encountered this issue?

ryanliszewski commented 2 years ago

@MosefAsad Are you running the app from the command line using react-native run-ios? If so, you'll need to set the envfile in the rn script when running locally like so:

ENVFILE=.env.development npx react-native run-ios

MosefAsad commented 2 years ago

@ryanliszewski I have and it works when I do but I should be able to run the IOS version of the app from Xcode and still have it expose variables to Info.plist as per the instructions outlined in the Read.me. There was a different project I worked on where we had the option of running through either the command line OR through Xcode. In either case, the Info.plist got updated correctly.

hit-cod commented 2 years ago

@ryanliszewski u saved my life

kiwavi commented 1 year ago

@luancurti I'm still facing this issue. I confirmed that my package has the fix you made above. Here is my react-native info output. Using the react-native-config 1.5.1 and followed all instructions. Instead of getting the correct value of the env variable, I am getting the value that's supposed to compute it in info.plist e.g $(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION)

I would really appreciate your input.

System: OS: macOS 12.6.3 CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz Memory: 35.75 MB / 8.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.15.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 9.5.0 - /usr/local/bin/npm Watchman: 2023.04.10.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.12.0 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9123335 Xcode: 14.1/14B47b - /usr/bin/xcodebuild Languages: Java: 17.0.5 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.4 => 0.71.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found info React Native v0.72.3 is now available (your project is running on v0.71.4). info Changelog: https://github.com/facebook/react-native/releases/tag/v0.72.3 info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.71.4 info For more info, check out "https://reactnative.dev/docs/upgrading".