lugg / react-native-config

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

'GeneratedDotEnv.m' file not found #187

Closed thedevdavid closed 4 years ago

thedevdavid commented 6 years ago

If I use this package with Cocoapods and follow the README's instructions, the iOS build fails every time. With C Preprocessor error "'GeneratedDotEnv.m' file not found".

Without any pods, it works.

Does anybody have any experience with this? I'm stuck for 2 days now because of this issue. I can't find any solution. I tried a lot of things by now.

M1chaelChen commented 5 years ago

Thanks to my colleague who found this magical commit which works perfectly. No workaround needed! yarn add react-native-config@luggit/react-native-config#1eb6ac01991210ddad2989857359a0f6ee35d734

"react-native": "0.61.2"

GaniduAsh commented 4 years ago

This relates with a permission issue , executing sudo chmod -R 777 /path of the source will solve the issue :)

zedtux commented 4 years ago

I had to adapt the post install script to make it working with RN 0.60.6 (and also to make it more Ruby style):

post_install do |installer|
  installer.pods_project.targets.each do |target|
    next unless target.name == 'react-native-config'

    phase = target.project.new(
      Xcodeproj::Project::Object::PBXShellScriptBuildPhase
    )
    phase.shell_script = <<-SCRIPT
      cd ../../ && \
      RNC_ROOT=./node_modules/react-native-config/ && \
      export SYMROOT=$RNC_ROOT/ios/ReactNativeConfig && \
      export BUILD_DIR=$RNC_ROOT/ios/ReactNativeConfig && \
      ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.ruby ${SRCROOT} ${SRCROOT}
    SCRIPT

    target.build_phases << phase
    target.build_phases.move(phase, 0)
  end
end

Adding the two ${SRCROOT} in order to define the place where is the .env file and where to build the GeneratedDotEnv.m file fixed the script.

pedro commented 4 years ago

:+1: #349 has been merged/released with 0.12

MaxInMoon commented 4 years ago

@pedro can you have a look on https://github.com/luggit/react-native-config/issues/414 please? I can't make it work with rn 0.61 and 0.12

vvusts commented 4 years ago

@zedtux I get error that .ruby file doesn’t exist. I have file on this path but it ends with .rb any idea?

zedtux commented 4 years ago

@vvusts well then just replace .ruby by .rb 😉

leemcmullen commented 4 years ago

I was experiencing this issue when trying to build on AppCenter with RN0.61 and react-native-config 0.12.

I was using the helpful script posted by @zedtux (https://github.com/luggit/react-native-config/issues/187#issuecomment-551493446) to get around it.

I'm now running RN0.61.5, I've upgraded to react-native-config 1.0 and AppCenter now builds without a problem.

UPDATE 17th April 2020 I've started getting the following issue: Build input file cannot be found: GeneratedDotEnv.m during local archive and during CI builds (on AppCenter). The only fix I can find is this (https://github.com/luggit/react-native-config/issues/391#issuecomment-571948199) but it's annoying because you have to update podspec whenever node_modules is re-built. Only fix which appeared to work consistently across local archiving and remote building/archiving.

samzmann commented 3 years ago

I recently ran into this issue. Simply updating react-native-config from 1.4.2 to 1.4.3 fixed the issue for me!

chenop commented 2 years ago

Clean xcode and rebuilding fixed it for me

anija commented 2 years ago

Experiencing this occasionally on 1.4.11

spsaucier commented 1 year ago

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.

dcsan commented 1 year ago

@chenop what do you mean by clean xcode ? I have a clean-all task as follows, are there any other ghostly artifacts that need to be hunted down?

clean-all:
    -rm ./package-lock.json
    -rm -rf ./node_modules
    -rm -rf ./ios/Pods
    -rm -rf ./ios/Podfile.lock
    -rm -fr $TMPDIR/metro-cache
    -rm $TMPDIR/haste-map-*
chenop commented 1 year ago

@dcsan clean xcode means: Product --> Clean Build Folder

ShepSims commented 1 year ago

@dcsan clean xcode means: Product --> Clean Build Folder

Useful Hotkey for this is (Shift + Command + K) in XCode

ko-devHong commented 1 year ago

This problem appears to be caused by the failure to find the .env configuration file. I put the .env file in the project and did the following action.

  1. xcode -> app icon lick => edit scheme click 스크린샷 2023-02-24 오전 11 07 40
  2. build => pre-actions
  3. write scripts

example

# Type a script or drag a script file from your workspace to insert its path.
PROD_FILE="${PROJECT_DIR}/../.env.production"
DEV_FILE="${PROJECT_DIR}/../.env.development"
if [ -f "$PROD_FILE" ]; then
    cp "$PROD_FILE" "${PROJECT_DIR}/../.env"
else 
    cp "$DEV_FILE" "${PROJECT_DIR}/../.env"
fi

"${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb" "${SRCROOT}/.." "${SRCROOT}/tmp.xcconfig"
ShepSims commented 1 year ago

I had accidentally deleted my tmp.xcconfig from the ios folder

a quick cd ios && pod install && cd .. from the project root directory worked for me as that regenerates the file

might also clean XCode before running again (⌘Command + K )

brascene commented 1 year ago

Pod install again and error was gone.