React-native-config: Does the 0.12 version support autolink?

Created on 26 Nov 2019  路  17Comments  路  Source: luggit/react-native-config

I'm wondering if 0.12 version support autolink cause:

First

In the readme there is:

Link the library:

$ react-native link react-native-config

But autolink should not need a link command, right?

Secondly

With these versions:

"react-native": "0.61.5",
"react-native-config": "^0.12.0",

I have an error on iOS:

built-in>:1:10: fatal error: '/Users/{USERNAME}/Library/Developer/Xcode/DerivedData/XXX-fdoedqtrcjsbppgvncqzfwelgcim/Build/Products/GeneratedInfoPlistDotEnv.h' file not found
#include "/Users/{USERNAME}/Library/Developer/Xcode/DerivedData/XXX-fdoedqtrcjsbppgvncqzfwelgcim/Build/Products/GeneratedInfoPlistDotEnv.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Command Preprocess failed with a nonzero exit code

See https://github.com/luggit/react-native-config/issues/187#issuecomment-554087367

Most helpful comment

Just a small idea for those that need speed like me.
I downgraded module to "0.11.7" and linked in xcode I passed this error for now.
Also:
In this file react-native.config.js on prject root it is required to add this to preven autolinking for this module on IOS (delete pod lock and pod folder as well and then pod update, pod install).

module.exports = {
  dependencies: {
    'react-native-config': {
      platforms: {
        ios: null
      }
    }
  }
}

All 17 comments

Same problem here

I have the same issue, and haven't been able to find a workaround.

I also tried everything from referenced thread and can鈥檛 pass this error on RN60.6

Just a small idea for those that need speed like me.
I downgraded module to "0.11.7" and linked in xcode I passed this error for now.
Also:
In this file react-native.config.js on prject root it is required to add this to preven autolinking for this module on IOS (delete pod lock and pod folder as well and then pod update, pod install).

module.exports = {
  dependencies: {
    'react-native-config': {
      platforms: {
        ios: null
      }
    }
  }
}

@vvusts thank you very much for this workaround.
It really works for me ([email protected] + [email protected] and manual linking with react-native-config project in xcode)
In Edit scheme I have added React to Build Targets before main Project also.
rnconfig linking

Auto linking worked for me but I had to clean up the old settings:

Open the iOS dir in Xcode.
Select the main file ***.xcodeproj
Select "Build settings"
Search for Preprocessor
On the field "Info.plist Other preprocessor Flags" delete the value : "-traditional"
On the field "Info.plist Preprocessor Prefix File" delete the value : "build/GeneratedInfoPlistDotEnv.h"
On The field "Preprocess Info.plist file" change the value to "No" 

@lapto which version of react-native-config did you use ?

@jitendralakhmani-proptiger

"react-native": "0.61.5"
"react-native-config": "0.12.0"

@lapto Did you add any post install script in your podfile?

@jitendralakhmani-proptiger
No script in build phase or anything in schemes. The package isn't listed in my Podfile either as autolink manages to find it from node_modules.

I do have the extra steps described in readme for the android build tho

@MaxInMoon I managed to autolink with v0.12. Using it with fastlane, I have written up my approach here and repo.

I downgraded module to "0.11.7" and linked in xcode I passed this error for now.

@vvusts @Dimon70007 what were the steps to link it "manually" in Xcode?

@grifotv for manual linking
1 - you should unlink library from xcode - react-native unlink react-native-config, add to react-native.config.js file this code:

module.exports = {
  dependencies: {
    'react-native-config': {
      platforms: {
        ios: null, // disable autolinking react-native-config for ios
      },
    },
  },
};

and run cd ios && rm -rf Pods && pod install; cd ../
2 - you should manually link react-native-config library to your project in xcode - see https://facebook.github.io/react-native/docs/0.59/linking-libraries-ios#manual-linking

thanks @Dimon70007

I did like you said, but instead of manually linking I used npx react-native link react-native-config following these steps https://github.com/luggit/react-native-config/issues/187#issuecomment-395585247

I tried! It work with auto linking:

"react-native": "0.61.5",
"react-native-config": "0.12.0",

It also work for ios Info.plist. The README did not mention that I need to change the key:

Within Info.plist, you now must access the values in your .env files with $() (e.g. $(MY_KEY_NAME)) rather than _RN_CONFIG.

Follow README file and use $(KEY) form will work

Please use 1.0.0 it's fixed in this version

What do you mean "fixed in this version" ? A simple yarn add react-native-config and that's all ?

Was this page helpful?
0 / 5 - 0 ratings