Giter Site home page Giter Site logo

Comments (63)

cristianrosu avatar cristianrosu commented on September 24, 2024 107

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.

lanekatris avatar lanekatris commented on September 24, 2024 69

@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]
    image
  • To here in Xcode under "libraries"
    image
  • And add the library under "linked frameworks and libraries"
    image

My error went away yelling about the "GeneratedInfoPlistDotEnv.h" not existing.

from react-native-config.

deno028 avatar deno028 commented on September 24, 2024 24

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

from react-native-config.

RyanMcDonald avatar RyanMcDonald commented on September 24, 2024 20

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.

denisdimitrov avatar denisdimitrov commented on September 24, 2024 18

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:

  1. Remove ${BUILD_DIR}/GeneratedInfoPlistDotEnv.h from Info.plist Preprocessor Prefix File
  2. Set Preprocess Info.plist File to No

from react-native-config.

eugenehp avatar eugenehp commented on September 24, 2024 15

I also found that INFOPLIST_PREFIX_HEADER should be adjusted as well. See my changes here: eugenehp@9792326

from react-native-config.

xilibro avatar xilibro commented on September 24, 2024 14

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.

fabriziomoscon avatar fabriziomoscon commented on September 24, 2024 12

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.

christophby avatar christophby commented on September 24, 2024 6

Same here

from react-native-config.

salujaharkirat avatar salujaharkirat commented on September 24, 2024 6

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.

mikefrancis avatar mikefrancis commented on September 24, 2024 6

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.

 avatar commented on September 24, 2024 4

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.

  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.

from react-native-config.

l3wi avatar l3wi commented on September 24, 2024 3

+1

edit: was having this issue until I realised I hadn't run "react-native link"

from react-native-config.

moroz0v avatar moroz0v commented on September 24, 2024 3

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.

from react-native-config.

robbykim avatar robbykim commented on September 24, 2024 2

+1

edit: had this issue even having run 'react-native link'

from react-native-config.

masiamj avatar masiamj commented on September 24, 2024 2

+1 - great fix @deno028

from react-native-config.

ujwal-setlur avatar ujwal-setlur commented on September 24, 2024 2

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.

ifero avatar ifero commented on September 24, 2024 2

If some one of you is using cocoapods this solution, from @birkir, works perfectly:
#187 (comment)

from react-native-config.

darrenchiu avatar darrenchiu commented on September 24, 2024 1

same here

from react-native-config.

coreyar avatar coreyar commented on September 24, 2024 1

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.

PeterRock avatar PeterRock commented on September 24, 2024 1

I fix it.
Set the value for Info.plist Preprocessor Prefix File
$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/GeneratedInfoPlistDotEnv.h

from react-native-config.

cocymsc1986 avatar cocymsc1986 commented on September 24, 2024 1

@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.

digitaldavenyc avatar digitaldavenyc commented on September 24, 2024 1

Changing Info.plist Preprocessor Prefix File to ${BUILD_DIR}/GeneratedInfoPlistDotEnv.hworked 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.

linhnh123 avatar linhnh123 commented on September 24, 2024 1

You can try, it work for me:
In Info.plist Preprocessor Prefix File:

${BUILD_DIR}/GeneratedInfoPlistDotEnv.h

screen shot 2017-07-01 at 6 25 17 pm

Run command:
react-native run-ios
Then you must be close and reopen the XCode, clean and build.

from react-native-config.

yomybaby avatar yomybaby commented on September 24, 2024 1

@mikefrancis, you save my time. 😄

from react-native-config.

RyanMcDonald avatar RyanMcDonald commented on September 24, 2024 1

@AmandeepSingh06 react-native link should add libReactNativeConfig.a to the workspace.

from react-native-config.

harrisrobin avatar harrisrobin commented on September 24, 2024 1

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.

mechazod avatar mechazod commented on September 24, 2024 1

@denisdimitrov Just followed your suggestion.

from react-native-config.

iamrutvik avatar iamrutvik commented on September 24, 2024

+1,

Even after linking it did not work

from react-native-config.

deno028 avatar deno028 commented on September 24, 2024

@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.

deno028 avatar deno028 commented on September 24, 2024

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.

wholcman avatar wholcman commented on September 24, 2024

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.

Johan-dutoit avatar Johan-dutoit commented on September 24, 2024

Any solution for this? Tried linking and different preprocessor.

from react-native-config.

deno028 avatar deno028 commented on September 24, 2024

@Johan-dutoit : What problem have you got? Any error message?

from react-native-config.

iamrutvik avatar iamrutvik commented on September 24, 2024

from react-native-config.

jordanmkoncz avatar jordanmkoncz commented on September 24, 2024

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.

Johan-dutoit avatar Johan-dutoit commented on September 24, 2024

@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.

PolGuixe avatar PolGuixe commented on September 24, 2024

In my case I couldn't find any. Is there way to better debug the process?

from react-native-config.

Knight704 avatar Knight704 commented on September 24, 2024

@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.

woodpav avatar woodpav commented on September 24, 2024

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.

anonymouskitler avatar anonymouskitler commented on September 24, 2024

Worked for me after adding ${BUILD_DIR}/GeneratedInfoPlistDotEnv.h in build settings while choosing the target

from react-native-config.

AmandeepSingh06 avatar AmandeepSingh06 commented on September 24, 2024

@RyanMcDonald: How did you find the libReactNativeConfig.a file in the workspace?

from react-native-config.

thedevdavid avatar thedevdavid commented on September 24, 2024

Still an issue. New React Native project with cocoapods, properly installed, then tried everything in this thread. Nothing...

from react-native-config.

ifero avatar ifero commented on September 24, 2024

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.

wwan5803 avatar wwan5803 commented on September 24, 2024

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.

wswebcreation avatar wswebcreation commented on September 24, 2024

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.

dancomanlive avatar dancomanlive commented on September 24, 2024

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.

salujaharkirat avatar salujaharkirat commented on September 24, 2024

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.

evanjmg avatar evanjmg commented on September 24, 2024

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.

ankitsehgal94 avatar ankitsehgal94 commented on September 24, 2024

@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]
    image
  • To here in Xcode under "libraries"
    image
  • And add the library under "linked frameworks and libraries"
    image

My error went away yelling about the "GeneratedInfoPlistDotEnv.h" not existing.

This is giving me linkers error.

from react-native-config.

Shweta-Porwal avatar Shweta-Porwal commented on September 24, 2024

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.

sandeep-sethia avatar sandeep-sethia commented on September 24, 2024

@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.

mehdihz avatar mehdihz commented on September 24, 2024

I've changed the below configs in "Build Settings" of project

  1. Info.plist Other Preprocessor Flags => -traditional
  2. Info.plist Preprocessor Prefix File => ${BUILD_DIR}/GeneratedInfoPlistDotEnv.h
  3. Preprocess Info.plist File => Yes

and it worked

from react-native-config.

nicolashemonic avatar nicolashemonic commented on September 24, 2024

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.

  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.

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.

Taylor123 avatar Taylor123 commented on September 24, 2024

@nicolashemonic do you have the GeneratedInfoPlistDotEnv.h in any of the preprocessing build settings?

from react-native-config.

tpucci avatar tpucci commented on September 24, 2024

@nicolashemonic Perhaps this will help: #391 (comment)

from react-native-config.

rafaelmaeuer avatar rafaelmaeuer commented on September 24, 2024

#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.

ElliDy avatar ElliDy commented on September 24, 2024

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.

lukewlms avatar lukewlms commented on September 24, 2024

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.

blinkyweezy avatar blinkyweezy commented on September 24, 2024

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.

GastonRosso avatar GastonRosso commented on September 24, 2024

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.

deno028 avatar deno028 commented on September 24, 2024

Sorry guys, I've been offline for a while. I think new versions this issue was solved.

from react-native-config.

spsaucier avatar spsaucier commented on September 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.