lugg / react-native-config

Bring some 12 factor love to your mobile apps!
MIT License
4.83k stars 656 forks source link

GeneratedInfoPlistDotEnv.h' file not found #83

Closed deno028 closed 2 years ago

deno028 commented 7 years ago

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.

christophby commented 7 years ago

Same here

darrenchiu commented 7 years ago

same here

robbykim commented 7 years ago

+1

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

l3wi commented 7 years ago

+1

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

iamrutvik commented 7 years ago

+1,

Even after linking it did not work

coreyar commented 7 years ago

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.

cristianrosu commented 7 years ago

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

deno028 commented 7 years ago

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

deno028 commented 7 years ago

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"

deno028 commented 7 years ago

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

masiamj commented 7 years ago

+1 - great fix @Deno028

wholcman commented 7 years ago

Try to double check if there is no space when you copy/paste ${CONFIGURATION_BUILD_DIR}/GeneratedInfoPlistDotEnv.h in the preprocessor prefix file.

Johan-dutoit commented 7 years ago

Any solution for this? Tried linking and different preprocessor.

deno028 commented 7 years ago

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

iamrutvik commented 7 years ago

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.

jordanmkoncz commented 7 years ago

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.

Johan-dutoit commented 7 years ago

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

salujaharkirat commented 7 years ago

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

PeterRock commented 7 years ago

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

eugenehp commented 7 years ago

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

ujwal-setlur commented 7 years ago

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.

xilibro commented 7 years ago

I install the latest version, and i found difference between README.md and web page In README.md:

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

cocymsc1986 commented 7 years ago

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

PolGuixe commented 7 years ago

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

digitaldavenyc commented 7 years ago

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

fabriziomoscon commented 7 years ago

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!

linhnh123 commented 7 years ago

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.

Knight704 commented 7 years ago

@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

mxkxf commented 7 years ago

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";
yomybaby commented 7 years ago

@mikefrancis, you save my time. 😄

RyanMcDonald commented 7 years ago

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.

woodpav commented 7 years ago

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.

anonymouskitler commented 7 years ago

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

AmandeepSingh06 commented 7 years ago

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

RyanMcDonald commented 7 years ago

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

thedevdavid commented 7 years ago

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

ifero commented 6 years ago

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

wwan5803 commented 6 years ago

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.

wswebcreation commented 6 years ago

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.

lanekatris commented 6 years ago

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

ifero commented 6 years ago

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

dancomanlive commented 6 years ago

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"

salujaharkirat commented 6 years ago

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.

evanjmg commented 5 years ago

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

moroz0v commented 5 years ago

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.

ankitsehgal94 commented 5 years ago

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

Shweta-Porwal commented 5 years ago

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.

harrisrobin commented 5 years ago

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
sandeep-sethia commented 5 years ago

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

mehdihz commented 5 years ago

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