Comments (63)
Make sure you do the preprocess settings under Build Settings while having the main project selected, not a target. This was causing the error in my case. 😄
from react-native-config.
@RyanMcDonald 's adding of the library worked for me. I had to do some manual steps:
- Drag from node modules/react-native-config/ios/[xcode project file]
- To here in Xcode under "libraries"
- And add the library under "linked frameworks and libraries"
My error went away yelling about the "GeneratedInfoPlistDotEnv.h" not existing.
from react-native-config.
After all I find the solution for this :
Set the value for Info.plist Preprocessor Prefix File
Instead of the one from documentation:
${CONFIGURATION_BUILD_DIR}/GeneratedInfoPlistDotEnv.h
from react-native-config.
I fixed this problem by manually linking libReactNativeConfig. react-native link
seems to only link the default scheme and not custom ones. So when the custom scheme is built, react-native-config never gets built, so the GeneratedInfoPlistDotEnv.h
file is never created.
Select your project > choose your target > General > Linked Frameworks and Libraries > Click the + > search for libReactNativeConfig.
from react-native-config.
I no longer needed the dependency and I removed it and it's pods, however I kept getting the following error:
- GeneratedInfoPlistDotEnv.h' file not found
The fix was simple yet time consuming:
- Remove
${BUILD_DIR}/GeneratedInfoPlistDotEnv.h
fromInfo.plist Preprocessor Prefix File
- Set
Preprocess Info.plist File
toNo
from react-native-config.
I also found that INFOPLIST_PREFIX_HEADER
should be adjusted as well. See my changes here: eugenehp@9792326
from react-native-config.
I install the latest version, and i found difference between README.md and web page
In README.md:
- Set
Info.plist Preprocessor Prefix File
to${CONFIGURATION_BUILD_DIR}/GeneratedInfoPlistDotEnv.h
on web page:
Set Info.plist Preprocessor Prefix File to
${BUILD_DIR}/GeneratedInfoPlistDotEnv.h
After i change my config as in READEME.md , it works well
from react-native-config.
I wasted a couple of hours with this issue as well... using version 5.0.0
and RN 0.45.1
The app was building for all SCHEMES using a Build Settings Release
but not for Debug
.
I fixed by applying this patch to my ios/MyApp.xcodeproj/project.pbxproj
- ONLY_ACTIVE_ARCH = NO;
+ ONLY_ACTIVE_ARCH = YES;
- INFOPLIST_PREFIX_HEADER = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/GeneratedInfoPlistDotEnv.h";
+ INFOPLIST_PREFIX_HEADER = "${BUILD_DIR}/GeneratedInfoPlistDotEnv.h";
I really hope this could help somebody else not to waste time!
from react-native-config.
Same here
from react-native-config.
I faced similar issue when I removed the node_modules folder to check something. Linking again using react-native also did not work.
So, tried unlinking and linking it again.
react-native unlink react-native-config
react-native link react-native-config
After this it works fine for me
from react-native-config.
Fixed this by opening ios/Project.xcodeproj
and changing all occurences of:
INFOPLIST_PREFIX_HEADER = "${CONFIGURATION_BUILD_DIR}/GeneratedInfoPlistDotEnv.h";
to:
INFOPLIST_PREFIX_HEADER = "${CONFIGURATION_BUILD_DIR}/../GeneratedInfoPlistDotEnv.h";
from react-native-config.
If you're coming from React version 0.60 and above, you should be referencing the package from GitHub instead of NPM. The author hasn'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.
-
yarn add https://github.com/luggit/react-native-config.git
-
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.
from react-native-config.
+1
edit: was having this issue until I realised I hadn't run "react-native link"
from react-native-config.
I install the latest version, and i found difference between README.md and web page
In README.md:
- Set
Info.plist Preprocessor Prefix File
to${CONFIGURATION_BUILD_DIR}/GeneratedInfoPlistDotEnv.h
on web page:
Set Info.plist Preprocessor Prefix File to
${BUILD_DIR}/GeneratedInfoPlistDotEnv.hAfter i change my config as in READEME.md , it works well
Setting ${CONFIGURATION_BUILD_DIR}/GeneratedInfoPlistDotEnv.h
on the project ONLY is what worked for me after trying everything else.
from react-native-config.
+1
edit: had this issue even having run 'react-native link'
from react-native-config.
+1 - great fix @deno028
from react-native-config.
I had to set it to the ${BUILD_DIR}/GeneratedInfoPlistDotEnv.h
Looking at the BuildDotenvConfig.ruby file, it writes the header file to:
# write it so the Info.plist preprocessor can access it
path = File.join(ENV["BUILD_DIR"], "GeneratedInfoPlistDotEnv.h")
File.open(path, "w") { |f| f.puts info_plist_defines_objc }
So, I ended up changing the Info.plist Preprocessor Prefix File setting to ${BUILD_DIR}/GeneratedInfoPlistDotEnv.h
This has to be done for the Project and all targets. In my case, in three places.
from react-native-config.
If some one of you is using cocoapods this solution, from @birkir, works perfectly:
#187 (comment)
from react-native-config.
same here
from react-native-config.
I had this problem using a previous version of react-native-config. I was able to resolve it by updating to 0.3.0, unlinking react-native-config, cleaning my project, and deleting ios/build.
from react-native-config.
I fix it.
Set the value for Info.plist Preprocessor Prefix File
$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/GeneratedInfoPlistDotEnv.h
from react-native-config.
@pedro will one of the above be accepted? There a few different answers here, seems to be different things work for different people.
Just to add my bit - for me, I deleted my node_modules folder, re-installed node modules and then installed and linked react-native-config. I then used ${BUILD_DIR}/GeneratedInfoPlistDotEnv.h instead of what is suggested in the readme and it worked for me.
from react-native-config.
Changing Info.plist Preprocessor Prefix File
to ${BUILD_DIR}/GeneratedInfoPlistDotEnv.h
worked for me as well.
I looked in the build directory and it seems the path for CONFIGURATION_BUILD_DIR
looks inside Debug-iphonesimulator
directory. The GeneratedInfoPlistDotEnv.h
is a directory above this in ios > build > Build > Products > GeneratedInfoPlistDotEnv.h
from react-native-config.
You can try, it work for me:
In Info.plist Preprocessor Prefix File
:
${BUILD_DIR}/GeneratedInfoPlistDotEnv.h
Run command:
react-native run-ios
Then you must be close and reopen the XCode, clean and build.
from react-native-config.
@mikefrancis, you save my time. 😄
from react-native-config.
@AmandeepSingh06 react-native link
should add libReactNativeConfig.a
to the workspace.
from react-native-config.
Adding the following to my Podfile after deleting ios/Pods
did it for me:
post_install do |installer|
installer.pods_project.targets.each do |target|
# Because: https://github.com/luggit/react-native-config/issues/365
if target.name == 'react-native-config'
phase = target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
phase.shell_script = "cd ../../"\
" && RNC_ROOT=./node_modules/react-native-config/"\
" && export SYMROOT=$RNC_ROOT/ios/ReactNativeConfig"\
" && ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.ruby"
target.build_phases << phase
target.build_phases.move(phase,0)
end
end
end
from react-native-config.
@denisdimitrov Just followed your suggestion.
from react-native-config.
+1,
Even after linking it did not work
from react-native-config.
@coreyar: I try both 0.3.0 and 0.3.1 unlink and relink but still failed. Are you using with multi build configurations instead of default "release and debug"?
@cristianrosu : This error throw from preprocessor.
from react-native-config.
I find that the BuildDotenvConfig.ruby wrote to wrong file:
Because the value of ENV["CONFIGURATION_BUILD_DIR"] diffrent with ${CONFIGURATION_BUILD_DIR}/GeneratedInfoPlistDotEnv.h in Preprocessor Prefix Info.plist config.
Reading env from .env.dev
Wrote to /Users/xxx/Library/Developer/Xcode/DerivedData/MyProject-agbpncwqiroipybewdcexatgmqjc/Build/Products/Release-iphoneos/GeneratedInfoPlistDotEnv.h
But the preprocess script check the link:
fatal error: '/Users/xxx/Library/Developer/Xcode/DerivedData/MyProject-agbpncwqiroipybewdcexatgmqjc/Build/Products/ReleaseDev-iphoneos/GeneratedInfoPlistDotEnv.h' file not found
#include "/Users/xxx/Library/Developer/Xcode/DerivedData/MyProject-agbpncwqiroipybewdcexatgmqjc/Build/Products/ReleaseDev-iphoneos/GeneratedInfoPlistDotEnv.h"
from react-native-config.
Try to double check if there is no space when you copy/paste ${CONFIGURATION_BUILD_DIR}/GeneratedInfoPlistDotEnv.h in the preprocessor prefix file.
from react-native-config.
Any solution for this? Tried linking and different preprocessor.
from react-native-config.
@Johan-dutoit : What problem have you got? Any error message?
from react-native-config.
from react-native-config.
I was getting this error for a new "Staging" scheme I had created. The standard release scheme was working but the Staging scheme was not. @deno028 your suggestion worked for me.
from react-native-config.
@deno028 I eventually got it to work with the new config, using your above solution. Guess it was just not cleaned/built correctly after I initially made the change.
from react-native-config.
In my case I couldn't find any. Is there way to better debug the process?
from react-native-config.
@xilibro thanks man, you saved my day!
All: in a nutshell the correct value for Preprocessor Prefix File is equal to ${BUILD_DIR}/GeneratedInfoPlistDotEnv.h
from react-native-config.
Correct me if I'm wrong but ${CONFIGURATION_BUILD_DIR}/../GeneratedInfoPlistDotEnv.h
and ${BUILD_DIR}/GeneratedInfoPlistDotEnv.h
are the same.
Make sure you've linked and make sure the Preprocessor setting in both Project and Target is build/GeneratedInfoPlistDotEnv.h
(after ${...}) has been applied.
from react-native-config.
Worked for me after adding ${BUILD_DIR}/GeneratedInfoPlistDotEnv.h
in build settings while choosing the target
from react-native-config.
@RyanMcDonald: How did you find the libReactNativeConfig.a file in the workspace?
from react-native-config.
Still an issue. New React Native project with cocoapods, properly installed, then tried everything in this thread. Nothing...
from react-native-config.
Hello everyone. I've found a very ugly but efficient solution.
If you're using cocoapods, Xcode will try to build react-native-config pod project first.
The thing that I've noticed is that BuildDotenvConfig.ruby
is never executed so that there is no way in which you will find the GeneratedDotEnv.m or the GeneratedInfoPlistDotEnv.h.
What I did was to create a .sh file in my project root:
cd project-root
vi build-prod-env.sh
inside build-prod-env.sh:
#!/bin/sh
export ENVFILE=".env.production"
export SYMROOT="./ReactNativeConfig"
export BUILD_DIR="../../../ios/build/Build/Products"
cd ./node_modules/react-native-config/ios
echo "----- Start Config -----"
ruby ./ReactNativeConfig/BuildDotenvConfig.ruby
echo "----- Building App -----"
cd -
react-native run-ios
- SYMROOT is needed to generate GeneratedDotEnv.m
- BUILD_DIR is needed to generate GeneratedInfoPlistDotEnv.h
This solution worked for me and I have created different .sh file based on the target and .env file to use
from react-native-config.
Well, my solution is to run yarn install react-native-config. As I pull my code from github, then I did npm install. All other package installed except react-native-config.
from react-native-config.
For all people who are also struggling with this, this answer might help. We are on react-native 0.51 and I couldn't get it working. Downgrading, linking and upgrading it helped.
from react-native-config.
I just did the manual linking and I am getting React/RCTDefines.h' file not found.
"react": "^16.0.0-beta.5",
"react-native": "^0.52.2"
from react-native-config.
If someone is facing this issue on a customised configuration(other than debug
and release
) you can try react-native-scheme-manager to handle the configurations. I have 3 configurations( debug, staging and release) now on iOS as I needed staging configuration for codepush. I was facing same issue until I used react-native-scheme-manager. This package modifies all your node_modules dependencies(.xproject) files based on configuration.
from react-native-config.
Whenever you add a new target you either need to add manually or if you use cocoapods, make sure it gets added to the target their in your Podfile
from react-native-config.
@RyanMcDonald 's adding of the library worked for me. I had to do some manual steps:
- Drag from node modules/react-native-config/ios/[xcode project file]
- To here in Xcode under "libraries"
- And add the library under "linked frameworks and libraries"
My error went away yelling about the "GeneratedInfoPlistDotEnv.h" not existing.
This is giving me linkers error.
from react-native-config.
I got this error when I forgot to run npm install inside my react native project before building the app. Steps followed : Went to react native project folder. Ran npm install from the Terminal. Restarted Xcode.Everything started working.
from react-native-config.
@xilibro thanks man, you saved my day!
All: in a nutshell the correct value for Preprocessor Prefix File is equal to ${BUILD_DIR}/GeneratedInfoPlistDotEnv.h
Didn't work for me. :(
from react-native-config.
I've changed the below configs in "Build Settings" of project
- Info.plist Other Preprocessor Flags => -traditional
- Info.plist Preprocessor Prefix File => ${BUILD_DIR}/GeneratedInfoPlistDotEnv.h
- Preprocess Info.plist File => Yes
and it worked
from react-native-config.
If you're coming from React version 0.60 and above, you should be referencing the package from GitHub instead of NPM. The author hasn'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.
yarn add https://github.com/luggit/react-native-config.git
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.
0.12
don't work with React Native 0.6+
auto linking or not.
I was obliged to downgrade to 0.11.7
and link the module manually, thanks to:
#414 (comment)
from react-native-config.
@nicolashemonic do you have the GeneratedInfoPlistDotEnv.h
in any of the preprocessing build settings?
from react-native-config.
@nicolashemonic Perhaps this will help: #391 (comment)
from react-native-config.
#391 (comment) describes how to generate the file, so it should give the right hint for anyone who needs to remove it.
from react-native-config.
Setting
${CONFIGURATION_BUILD_DIR}/GeneratedInfoPlistDotEnv.h
on the project ONLY is what worked for me after trying everything else.
Thanks @moroz0v, this worked for me. Setting it ONLY on project and NOT on the targets is the secret here.
from react-native-config.
My solution was pretty specific - mine was failing only when testing with Detox, but working fine with normal run-ios
. I fixed it by changing this setting in my Detox build command:
-derivedDataPath ios/build
To point to the Xcode DerivedData directory, where the .h file can actually be found:
/Users/me/Library/Developer/Xcode/DerivedData/mobile2mr-xxxx
from react-native-config.
for anyone who couldn't find a solution, how i solved mine was to navigate to the folder that was mentioned in the error message. mine was /Users/user/Library/Developer/Xcode/DerivedData/app-gehbcoezzoencvciaviqaurqghcg/Build
and ran this code in the terminal at that folder, touch GeneratedDotEnv.m GeneratedInfoPlistDotEnv.h && echo "#define DOT_ENV @{ };" >> GeneratedDotEnv.m
. cleaned the project and it worked :))
from react-native-config.
If anyone is still having the problem, my issue was that I was opening Xcode in ios folder, what solved it for my was opening xcworkspace file from Xcode.
from react-native-config.
Sorry guys, I've been offline for a while. I think new versions this issue was solved.
from react-native-config.
We fixed by removing the requirements for GeneratedInfoPlistDotEnv.h
, since it's not recommended by the react-native-config
Readme anymore, and then we followed the instructions towards Config.xcconfig enabling env vars in Info.plist: https://github.com/luggit/react-native-config#availability-in-build-settings-and-infoplist, making sure that our Info.plist was using the proper $(VAR)
syntax.
from react-native-config.
Related Issues (20)
- Configuration not updating on updating new key in env HOT 3
- Multiple commands produce 'node_modules/react-native-config/ios/ReactNativeConfig/GeneratedDotEnv.m' HOT 7
- it is working react native 0.72.0 ? HOT 15
- How to modify the content of ".env file" by command in "scripts" of "package.json". HOT 1
- Change env value programatically (with persistence) HOT 3
- The app is always running in release mode after the RN upgrade from 0.71.7 to 0.72.3 HOT 2
- SigningConfig "releaseStaging" is missing required property "storePassword" when using gradlew to build HOT 1
- Release build unable to access .env file on android HOT 16
- Reference variables
- Missing .env in Github CI/CD in Android HOT 3
- Changes only propagate if I remove derived data HOT 11
- output.versionCodeOverride is not getting override when version code is coming from .env
- Config is empty after upgrade to RN 0.71 HOT 32
- "/tmp/envfile" is buggy when its contents are empty string (iOS)
- Cannot invoke method toInteger() on null object HOT 2
- Inconsistent Environment File Loading in Android Studio vs React Native CLI
- ERROR in ./src/CONFIG.ts 3:0-41 [web-server] Module not found: Error: Can't resolve 'react-native-config' in '/Volumes/Personal/code-work/rn-projects/zaions/expensify-app-fork/src'
- is it possible to pass params but not set ENVFILE when run assemble release HOT 1
- How to import NSExceptionDomains as an environment variable?
- Variable are UNDEFINED on IOS HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-config.