Closed deno028 closed 2 years ago
Same here
same here
+1
edit: had this issue even having run 'react-native link'
+1
edit: was having this issue until I realised I hadn't run "react-native link"
+1,
Even after linking it did not work
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.
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. 😄
@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.
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"
After all I find the solution for this :
Set the value for Info.plist Preprocessor Prefix File ${SYMROOT}/Release$(EFFECTIVE_PLATFORM_NAME)/GeneratedInfoPlistDotEnv.h
Instead of the one from documentation: ${CONFIGURATION_BUILD_DIR}/GeneratedInfoPlistDotEnv.h
+1 - great fix @Deno028
Try to double check if there is no space when you copy/paste ${CONFIGURATION_BUILD_DIR}/GeneratedInfoPlistDotEnv.h in the preprocessor prefix file.
Any solution for this? Tried linking and different preprocessor.
@Johan-dutoit : What problem have you got? Any error message?
Upgrade or downgrade library version based on your react native version. I was using RN 0.38 and I was using latest version of react native config. I had to downgrade config version to make it work
Sent from my iPhone
On 05-Apr-2017, at 10:26 AM, Thanh Lam notifications@github.com wrote:
@Johan-dutoit : What problem have you got? Any error message?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
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.
@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.
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
I fix it.
Set the value for Info.plist Preprocessor Prefix File
$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/GeneratedInfoPlistDotEnv.h
I also found that INFOPLIST_PREFIX_HEADER
should be adjusted as well. See my changes here: https://github.com/eugenehp/react-native-config/commit/9792326107a3204110c723dfee244f8d067bb786
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.
I install the latest version, and i found difference between README.md and web page In README.md:
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
@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.
In my case I couldn't find any. Is there way to better debug the process?
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
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!
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.
@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
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";
@mikefrancis, you save my time. 😄
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.
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.
Worked for me after adding ${BUILD_DIR}/GeneratedInfoPlistDotEnv.h
in build settings while choosing the target
@RyanMcDonald: How did you find the libReactNativeConfig.a file in the workspace?
@AmandeepSingh06 react-native link
should add libReactNativeConfig.a
to the workspace.
Still an issue. New React Native project with cocoapods, properly installed, then tried everything in this thread. Nothing...
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
This solution worked for me and I have created different .sh file based on the target and .env file to use
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.
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.
@RyanMcDonald 's adding of the library worked for me. I had to do some manual steps:
My error went away yelling about the "GeneratedInfoPlistDotEnv.h" not existing.
If some one of you is using cocoapods this solution, from @birkir, works perfectly: https://github.com/luggit/react-native-config/issues/187#issuecomment-353156419
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"
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.
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
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
Setting ${CONFIGURATION_BUILD_DIR}/GeneratedInfoPlistDotEnv.h
on the project ONLY is what worked for me after trying everything else.
@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.
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.
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
@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. :(
I've changed the below configs in "Build Settings" of project
and it worked
I created a new scheme with new Configuration build : releaseDev
"react-native": "0.37.0", "react-native-config": "^0.3.0",
When archiving I got this error:
fatal error: '/Users/xxx/Library/Developer/Xcode/DerivedData/MyProject-xxx/Build/Intermediates/ArchiveIntermediates/myDevScheme/BuildProductsPath/ReleaseDev-iphoneos/GeneratedInfoPlistDotEnv.h' file not found
Notes: it works with default configuration builds: release and debug.