react-native-config: `GeneratedInfoPlistDotEnv.h` file not found and iOS command not working

@pedro

First of all tnx for this great module. I do have some questions remarks about it.

Config:

OS: OSX 10.13.2 (17C88) XCODE: 9.2 (9C40b) react-native: 0.51 react-native-config: 0.11.5

When I follow the instructions in the readme I get everything working for Android but not for iOS

GeneratedInfoPlistDotEnv.h file not found

When I follow the instructions for iOS in the readme I get the first error, which is GeneratedInfoPlistDotEnv.h file not found. I’ve read the issue list and saw more people have this issue, see https://github.com/luggit/react-native-config/issues/83. I finally found a solution in issue 125 where they say the problem lies in the react-native link command that works differently between react-native 0.49.3 and 0.50.0. By:

  • downgrading react-native
  • executing react-native link
  • upgrading to latest version of react-native

I solved the first problem

ENVFILE=.env.prod react-native run-ios not working

According to the docs I should be able to use ENVFILE=.env.prod react-native run-ios but because we hardcoded the command echo ".env" > /tmp/envfile I can’t pass any other value. I then found a solution in issue https://github.com/luggit/react-native-config/issues/131 where I’ve added my solution.

Question

Are both really issues, or am I doing something wrong. If they are I can create a PR for you to update the docs with these steps.

Like to hear from you

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 6
  • Comments: 15

Most upvoted comments

@pdoggi thanks! Manual linking worked (first 2 steps), didn’t need to modify ios/app.xcodeproj/project.pbxproj

So, I was able to fix this without actually downgrading.

This assumes you’ve followed the iOS Setup instructions to the dot at the time of me writing this.

Assumptions:

  • You’re using React Native version 0.51.0
  • You’re using react-native-config 0.11.5

To fix:

  • Open ios/app.xcodeproj/project.pbxproj
  • Open the “Find & Replace” tool of your preferred text editor
  • Replace all instances of ${BUILD_DIR}/GeneratedInfoPlistDotEnv.h with this instead: ${CONFIGURATION_BUILD_DIR}/../GeneratedInfoPlistDotEnv.h

Also make sure your .env file doesn’t define environment variables with any spaces:

e.g.

FOOD='pizza'    // this is good
FOOD = 'pizza'  // this is bad

@gyss , @prathammehta Manual linking did it for me. I’m also using ${CONFIGURATION_BUILD_DIR}/../GeneratedInfoPlistDotEnv.h, not sure if that helps or not. I’m on react-native 0.55.4, react-native-config 0.11.5. Good luck!

You can still use 0.11.7 with RN 0.60 Setting Preprocessor Prefix File to:

${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/GeneratedInfoPlistDotEnv.h

Fixed this for me with RN 0.60 and xcode 11.2.1

@pdoggi since this repo looks like is no longer maintained I’m going to go with my own solution. It’s safer for now.

If you’re coming from React version 0.60 and above, you should be referencing the package from GitHub instead of NPM. The author haven’t released auto-linking support on NPM yet, even though it’s already merged!?

Try these steps after you unlink and uninstall the existing version of react-native-config. Remember to revert to default Info.plist preprocessor settings in XCode build settings.

  1. yarn add https://github.com/luggit/react-native-config.git

  2. cd ios && pod install

You don’t have to add any other post-install scripts, just run the app like usual and it should work fine. Make sure you undo any other fixes before doing this.