Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with RN 0.60.4 #365

Closed
ravimaurya-nickelfox opened this issue Jul 23, 2019 · 51 comments
Closed

Not working with RN 0.60.4 #365

ravimaurya-nickelfox opened this issue Jul 23, 2019 · 51 comments

Comments

@ravimaurya-nickelfox
Copy link

The library is not working with RN 0.60.4, automatic linking is not working. If I try to link manually, it throws errors. On pod install it produces error 'GeneratedDotEnv.m' file not found.

Any help? 🆘

@Elvinra
Copy link

Elvinra commented Jul 23, 2019

You are using react-native-config from npmjs, try to use this librairy directly from github
yarn add https://github.com/luggit/react-native-config

@gwmccull
Copy link

I ended up using this specific commit and then I didn't need the post-install scripts mentioned in other issues
github.com/luggit/react-native-config.git#89a602b

@ravimaurya-nickelfox
Copy link
Author

@Elvinra that worked for me!!

Another fix, if you install with npmjs, then
yarn add react-native-config
Open podfile and add

post_install do |installer|
 installer.pods_project.targets.each do |target|
   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

cd iOS && pod install

@dineshmm23
Copy link

dineshmm23 commented Jul 24, 2019

@Elvinra we can also work but clean and rebulding issues causes back again
Please check that node_modules/react-native-config/ios/ReactNativeConfig contains same up to date files from repo.

Nevermind, just found out that this repo is updated but not published to npm.
Replace "react-native-toasty": "current version" with "react-native-config": "git+https://github.com/luggit/react-native-config.git"

Then you can run pod install without issue.

Still I don't understand why the npm version is not updated anymore.

@GuillaumeMunsch
Copy link

Credit goes to @bockc here prscX/react-native-toasty#12 (comment)

@fariasmark
Copy link

I need help! I've try @dineshmm23's solution but I'm still getting this error:

ruby: No such file or directory -- ./node_modules/react-native-config//ios/ReactNativeConfig/BuildDotenvConfig.ruby (LoadError)

Command PhaseScriptExecution failed with a nonzero exit code

@gwmccull
Copy link

@fariasmark Are you missing the script? What version of react-native-config and react-native are you using?

The error that you reported is not the same as the original issue so you may want to open your own issue

@ravimaurya-nickelfox
Copy link
Author

@fariasmark just follow these steps:

yarn add react-native-config

then go to ios>Podfile and add below code at the bottom of file.

post_install do |installer|
 installer.pods_project.targets.each do |target|
   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

then run pod install

now run react-native run-ios

@mchudy
Copy link

mchudy commented Jul 25, 2019

@fariasmark Try replacing BuildDotenvConfig.ruby with BuildDotenvConfig.rb. It helped in my case.

@s123121
Copy link

s123121 commented Jul 28, 2019

Here is the guide for some poor soul javascript dev like me out there:

  1. yarn add luggit/react-native-config#master (don't use the version on npm or you will spend way too much time to figure out how this work)
    Note: if you want to anchor your version then use this commit instead of master 1eb6ac0
  2. Follow exactly like the README, you don't need to add any code inside your Podfile
    After pod install there will be some warning like this [!] react-native-config has added 1 script phase. (which mean you are doing this right)
    2a. If your want to support Info.plist, replace __RN_CONFIG_xxx to $(xxx) inside your Info.plist file
  3. Build and run your project like normal

On the side note, the README should be restructure for it is very confusing

@ninjz
Copy link

ninjz commented Jul 29, 2019

@s123121 I've done everything that you said. What does your Pre-actions script look like inside of schemes > Build > Pre-actions ? Mine looks like:

echo ".env.testing" > /tmp/envfile
${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb "${SRCROOT}/.." "${SRCROOT}/tmp.xcconfig"

Not sure if i'm following the instruction correctly for when I want my configs in info.plist

@hkung77
Copy link

hkung77 commented Jul 30, 2019

I'm also having some trouble with getting RN0.60.4 to work with this library. I get an error in the preprocessing Info.plist

GeneratedInfoPlistDotEnv.h' file not found

It seems like there's so many different fixes each for different versions and if people have multiple envs.

Can we get some way of version controlling each solution and have an updated example. (it's currently at RN50). Perhaps just having a proper example for each version will alleviate all the issues popping up because this library doesn't work with this version.

@rexhuynh
Copy link

@s123121 thank you alot

@rexhuynh
Copy link

@ninjz you are correct remember that choose your target for Provide build settings form
Screen Shot 2019-07-30 at 1 41 46 PM

@ninjz
Copy link

ninjz commented Jul 30, 2019

@rexhuynh Thanks so much that seemed to solve my issue

@ZHIENDUS
Copy link

@rexhuynh you save my day

@wygkzqa
Copy link

wygkzqa commented Aug 1, 2019

@Elvinra that worked for me!!

Another fix, if you install with npmjs, then
yarn add react-native-config
Open podfile and add

post_install do |installer|
 installer.pods_project.targets.each do |target|
   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

cd iOS && pod install

Thanks. It works

@kdenz
Copy link

kdenz commented Aug 1, 2019

What I'm doing for RN 0.60.4 (Upgraded from 0.59.9) is basically

  1. Change react-native-config ver to master "react-native-config": "github:luggit/react-native-config#master" or lock commit to 1eb6ac0 as @s123121 said. Then npm install it
  2. (if exists) Remove pod 'react-native-config', :path => '../node_modules/react-native-config' in Podfile
  3. (if exists) Remove the package link at Link Binary with libraries in your XCode Workspace
  4. Add the following to Podfile, notice that it's .rb instead of .ruby for me (Thanks @mchudy)
post_install do |installer|
 installer.pods_project.targets.each do |target|
   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.rb"
     
     target.build_phases << phase
     target.build_phases.move(phase,0)
   end
 end
end
  1. run pod install at ios folder

But I'm getting this now, anyone knows why?

/Users/kaiden-dragon/dev/dragon-frontend/react-native/node_modules/react-native-config/ios/ReactNativeConfig/ReadDotEnv.rb:27:in `join': no implicit conversion of nil into String (TypeError)
	from /Users/kaiden-dragon/dev/dragon-frontend/react-native/node_modules/react-native-config/ios/ReactNativeConfig/ReadDotEnv.rb:27:in `read_dot_env'
	from ./node_modules/react-native-config//ios/ReactNativeConfig/BuildDotenvConfig.rb:15:in `<main>'
reading env file from  and writing .m to 
going to read env file from root folder 
Command PhaseScriptExecution failed with a nonzero exit code

@Mlobaievskyi
Copy link

@kdenz if remove script from Podfile it tun with react-native run-ios, but when try to archive - it fails with
BuildProductsPath/GeneratedInfoPlistDotEnv.h' file not found

@kdenz
Copy link

kdenz commented Aug 1, 2019

@Mlobaievskyi That's so wierd lol
I'm still trying to figure out this error

/Users/kaiden-dragon/dev/dragon-frontend/react-native/node_modules/react-native-config/ios/ReactNativeConfig/ReadDotEnv.rb:27:in `join': no implicit conversion of nil into String (TypeError)
	from /Users/kaiden-dragon/dev/dragon-frontend/react-native/node_modules/react-native-config/ios/ReactNativeConfig/ReadDotEnv.rb:27:in `read_dot_env'
	from ./node_modules/react-native-config//ios/ReactNativeConfig/BuildDotenvConfig.rb:15:in `<main>'
reading env file from  and writing .m to 
going to read env file from root folder 
Command PhaseScriptExecution failed with a nonzero exit code

@Mlobaievskyi
Copy link

Found solution

  1. yarn add react-native-config
  2. manually link https://facebook.github.io/react-native/docs/linking-libraries-ios.html#manual-linking
  3. add next to react-native.config.js
module.exports = {
  dependencies: {
    'react-native-config': {
      platforms: {
        ios: null
      }
    }
  }
}
  1. react-native run-ios (archive also work)

@danvass
Copy link

danvass commented Aug 1, 2019

Can't seem to get this running either. Followed various options from above and none have worked. Got the same error as @kdenz when I tried his one.

I'll see if I can get it going with a react-native init and see if I can figure out what's going on from there.

@aajkishore
Copy link

This behavior seems to be extremely inconsistent. Everything was working fine for me. Then I deleted the build folder, tried to build again, and this error came back. Then I unlinked the library
react-native unlink react-native-config which deleted this line
pod 'react-native-config', :path => '../node_modules/react-native-config' from Podfile.

And everything stated working again. Podfile does have the solution provided by @ravimaurya-nickelfox .

@kdenz
Copy link

kdenz commented Aug 5, 2019

What worked for me now on 0.60.4, inspired by @Mlobaievskyi and @s123121 -

  1. Change react-native-config ver to master "react-native-config": "github:luggit/react-native-config#master" or lock commit to 1eb6ac0 as @s123121 said. Then npm install it
  2. Follow the steps here to manually link the package https://facebook.github.io/react-native/docs/linking-libraries-ios.html#manual-linking

  3. And then put the following into react-native.config.js at root folder (Not sure if necessary)
module.exports = {
  dependencies: {
    'react-native-config': {
      platforms: {
        ios: null
      }
    }
  }
}
  1. Remember to remove this snippet from Podfile
post_install do |installer|
 installer.pods_project.targets.each do |target|
   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.rb"
     
     target.build_phases << phase
     target.build_phases.move(phase,0)
   end
 end
end

and the line pod 'react-native-config', :path => '../node_modules/react-native-config'
then run pod install again (To be safe you can delete Podfile.lock first)

Then I was getting 'GeneratedDotEnv.m' file not found. error
After battling it a while I realized from this PR (1eb6ac0) that I should remove all these preprocess settings. After that 'GeneratedDotEnv.m' file not found. error is gone and it works for me.
image

@ThomasLarge
Copy link

post_install do |installer|
 installer.pods_project.targets.each do |target|
   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

THIS WORKS!!!!!!!!!!!!

@iba-ragi
Copy link

Do not trust the latest README.
If you want to use info.plist and Js,

  1. Follow this document.
  2. Put the following code in your podfile
  3. Everything will work!!!!
post_install do |installer|
 installer.pods_project.targets.each do |target|
   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

@TakaKeiji
Copy link

You are using react-native-config from npmjs, try to use this librairy directly from github
yarn add https://github.com/luggit/react-native-config

This has worked for me correctly

@TrebuhD
Copy link

TrebuhD commented Sep 5, 2019

Can we have a new release from master? I don't feel comfortable hardcoding a repository link in my package.json.

@mehdihz
Copy link

mehdihz commented Sep 25, 2019

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

@felippepuhle
Copy link

@mehdihz npm version?

@MaximeConan
Copy link

MaximeConan commented Oct 24, 2019

   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

@ravimaurya-nickelfox You're the best ! :D

@mehdihz
Copy link

mehdihz commented Oct 25, 2019

@mehdihz npm version?

Sorry for late answer. My npm version: 6.9.0

@bars0um
Copy link
Contributor

bars0um commented Oct 29, 2019

I was beating my head at this for the better part of a day. Everything worked fine with little to no intervention on react 0.57 for me, moving to 0.60+ was a ball!

In any case what I needed was the following:

  1. Store variables in the binary (e.g. URL and pinned public keys) and access them in JS (Config.X)
  2. Pass variables to Info.plist (picked up by some sdks such as FB) $(MYVAR)
  3. Pass variables through the bundler (bundle version info and other vars) ENVFILE=.env.x react-native run-ios

react-native-config did 1 and 2 for me, but for 3, I needed to use react-native-dotenv.

Now my issue could be that these both read/write to /tmp/envfile but in essence this should not be an issue because you basically only want one .env.XYZ file to be consumed on any one build.

For 1, I needed only to import the Config variable and use as needed. Between builds I need to rebuild since this is passed through the binary.

For 2, I needed to do some acrobatics and to stand on my head a bit. Basically the documentation seems to have changed and you no longer should be using the prefix __RN_CONFIG_VARNAME but instead $(VARNAME) only.

Here also you need to make sure that your xcconfig file references the tmp.xcconfig file which should be generated by an early build phase step that you have to create

${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb "${SRCROOT}/.." "${SRCROOT}/tmp.xcconfig

When I ran this command in terminal alone I noticed that it generated an empty tmp.xcconfig which was simply because I had not created a /tmp/envfile. Now my scheme build pre-action does this:

export ENVFILE=.env.test
echo $ENVFILE > /tmp/envfile   
echo $ENVFILE > /tmp/dotenv

So it's not that the build doesn't have a /tmp/envfile to work with...at this point I figured it must have been deleted somewhere in the series of scripts running.

Reviewing the build logs when I had issues with vars not making it into the package, I noticed a subtle message:


*** Missing .env file ****


In the same log I noted that a previous run of BuildXCConfig.rb had no issues. Reviewing BuildXCConfig I realized that the last step deletes the /tmp/envfile...which of course was the crux of the problem, at least for my specific issue, I've create a pull request here for this: #404

The additional step needed for 2 to work properly is to make sure that your Project->Info->Configurations configured file (for me Pods-Project-Prod.xcconfig) calls

#include? "tmp.xcconfig"

at the top.

Note this gets stamped any time you do a pod install so we'd need a post_install step to put it back in.

For 3 I still can't find a very clean way of doing this for xcode. At present you need the scheme build pre-action to create the /tmp/dotenv file, but to pass ENVFILE to the bundler, I basically had to modify the node_modules/react-native/scripts/node-binary.sh and add the export there:

export ENVFILE=$(cat /tmp/dotenv)

In React < 0.60 I could add this bit to the React.xproj packager build phase, however with React > 0.60 the logic of the scripts have changed.

Edit

As per the note above here is a post install to configure the xcconfig file

post_install do |installer|
  installer.pods_project.targets.each do |target|
      if(target.name=='Pods-YOURPROJECTTARGET')
          puts "Updating #{target.name} for react-native-config configs to be included"
          target.build_configurations.each do |config|
              xcconfig_path = config.base_configuration_reference.real_path
              xcconfig = File.read(xcconfig_path)
              nativeconfig = '#include? "tmp.xcconfig"' + "\r\n" + xcconfig
              File.open(xcconfig_path, "w") { |file|  file << nativeconfig }
          end      
        end
  end
end

Edit 2

you can add the packager ENVFILE option to the node launch script using a post install in your package.json:

# package.json
scripts: {
...
"postinstall":"sh ./scripts/postinstall.sh"
...
}

and

grep -q ENVFILE ./node_modules/react-native/scripts/node-binary.sh
if [ $? -eq 0 ]
then
        echo node ENVFILE patch already applied
else
        echo "export ENVFILE=$(cat /tmp/dotenv)" >> ./node_modules/react-native/scripts/node-binary.sh
fi

exit 0

@EliYenn
Copy link

EliYenn commented Nov 1, 2019

post_install do |installer|
installer.pods_project.targets.each do |target|
if(target.name=='Pods-YOURPROJECTTARGET')
puts "Updating #{target.name} for react-native-config configs to be included"
target.build_configurations.each do |config|
xcconfig_path = config.base_configuration_reference.real_path
xcconfig = File.read(xcconfig_path)
nativeconfig = '#include? "tmp.xcconfig"' + "\r\n" + xcconfig
File.open(xcconfig_path, "w") { |file| file << nativeconfig }
end
end
end
end

After running, it can be used by using acts-native run-ios, but after deleting ipa, the edit config is empty

@selcukitmis
Copy link

selcukitmis commented Nov 14, 2019

Clear xcode cache with

shift + option + cmd + k

@jayzyaj
Copy link

jayzyaj commented Nov 20, 2019

I just upgraded my React Native version to 0.61.4 and react-native-config ^0.12.0. @kdenz solution worked for me.

@tmaly1980
Copy link

tmaly1980 commented Nov 29, 2019

@Elvinra that worked for me!!

Another fix, if you install with npmjs, then
yarn add react-native-config
Open podfile and add

post_install do |installer|
 installer.pods_project.targets.each do |target|
   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

cd iOS && pod install

I had to replace that last line with:

" && ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.rb \"${SRC_ROOT}/../\" \"${SYMROOT}\""

@mguay22
Copy link
Contributor

mguay22 commented Dec 19, 2019

Thank you! @tmaly1980

@alexpyoung
Copy link

FYI on RN 0.61.2:

In addition to #365 (comment) when using v0.11.7, v0.12.0 alleviates the need for this patch, after some additional small changes to your project

@abo-rythm
Copy link

abo-rythm commented Jan 7, 2020

The library is not working with RN 0.60.4, automatic linking is not working. If I try to link manually, it throws errors. On pod install it produces error 'GeneratedDotEnv.m' file not found.

Any help? 🆘

For me, the problem was that ProjectTests target had the Preprocessor Prefix File set the same as the project, and it should be empty.

Otherwise, It worked only with the steps in the documentation.

react-native 0.60.5
react-native.config 0.12.0

@khalilTN
Copy link

khalilTN commented Apr 30, 2020

Is there a solution without having to add code to Podfile ?
I also have this problem after upgrading react-native from 0.59.10 to 0.60.0

@gevgasparyan
Copy link

If you are using Pods just add (without react-native link react-native-config)

pod 'react-native-config', :path => '../node_modules/react-native-config/react-native-config.podspec'
in your Podfile

@pragneshpj
Copy link

I got .env value in AppDelegate.m
but didn't get in info.plist.
NSDictionary *config = [ReactNativeConfig env];
NSLog(@"Configure: %@", config);

"react-native": "0.61.5"
"react-native-config": "luggit/react-native-config#master",

can anyone help me. (Please share steps)

Thanks

@tmaly1980
Copy link

I was getting the "ld: library not found for -lReactNativeConfig" error after switching over to CocoaPods. I removed ReactNativeConfig from the Libraries folder, but forgot to clean up "Link Binary with Libraries" under Build Phases.

@gilador
Copy link

gilador commented Oct 27, 2020

The error is the shell script is referencing a wrong path with the wrong filename

I had to edit 2 files:

  1. Podfile:
    " && RNC_ROOT=./node_modules/react-native-config/"\ to without '/' at the end =>
    " && RNC_ROOT=./node_modules/react-native-config"\ since if you will take closer look, the error is saying that path:
    /node_modules/react-native-config//ios/ReactNativeConfig wasn’t found.

  2. project.pbxproj:
    in this file i had to make sure i am referecing an exiting file, the file changes over the lib versions, so:
    shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n\"${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb\" \"${SRCROOT}/..\" \"${SRCROOT}/release.xcconfig\"\n";
    to
    shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n\"${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildDotenvConfig.ruby\" \"${SRCROOT}/..\" \"${SRCROOT}/release.xcconfig\"\n";

@okcoker
Copy link

okcoker commented Dec 7, 2020

I'm using react-native-config 1.4.1 and was running into the empty object problem on ios so I added a new run script within Build Phases and got the config correctly populated as expected:

Update:

cd "$SRCROOT/../"
RNC_ROOT_DIR=$(pwd)
cd -

echo "Setting env for configuration: ${CONFIGURATION} with root dir: ${RNC_ROOT_DIR}"

if [ "${CONFIGURATION}" = "Release" ]; then
    echo "$RNC_ROOT_DIR/.env.production" > /tmp/envfile
    "$RNC_ROOT_DIR/node_modules/react-native-config/ios/ReactNativeConfig/BuildDotenvConfig.rb" "$RNC_ROOT_DIR/.env.production" "$RNC_ROOT_DIR/node_modules/react-native-config/ios/ReactNativeConfig"
else
    echo "$RNC_ROOT_DIR/.env.development" > /tmp/envfile
    "$RNC_ROOT_DIR/node_modules/react-native-config/ios/ReactNativeConfig/BuildDotenvConfig.rb" "$RNC_ROOT_DIR/.env.development" "$RNC_ROOT_DIR/node_modules/react-native-config/ios/ReactNativeConfig"
fi

Create a new run script and paste the above in there. Update your .env files within the script above accordingly. I'm using .env.production and .env.development for release and debug builds respectively.

Screen Shot 2020-12-07 at 11 45 07 PM

In order to change between debug and release builds you can go to "Edit schemes" for your target:

Screen Shot 2020-12-07 at 11 33 20 PM copy

And select between the 2 builds:

Screen Shot 2020-12-07 at 11 33 53 PM

The next build and run of your app should contain the contents between your various env files.

@0011001011
Copy link

this should be /open

@timorss
Copy link

timorss commented Feb 21, 2024

@ninjz you are correct remember that choose your target for Provide build settings form Screen Shot 2019-07-30 at 1 41 46 PM

Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests