-1

I have a react native named MyApp and it is two app sides managed in single codebase.The app is managed by react native config during its build the config is set to that specific environment like env1 or env2.For Creating the build i run the script npm run ios:env1 and npm run ios:env2 and it sets the enviroment first and then the apps build is generated and also the apps routes are setted according to that setted config environment.so it works fine for this part.

But now when i put the apps to testflight i need to create their respective archive builds but i am not getting how to do that as before the archive build i need to set the environment like env1 or env2. I read the documentation of react native config also from below it told to create schemes n all for each environment also did that but still i get error the error is **"Command PhaseScriptExecution failed with a nonzero exit code" ** which from react native config. Also you can check the below image for more reference. My .env.env1 file is stored in .env folder in root direcotry of my project

I have also added a script inside the scheme in Pre-actions in Build please refer below image for the script is wrote in the tareget in schemes

Also Below is the link for the react native config documentation which i followed. react-native-config documentation

The Errors is get

Note: "myapp-reactnative" is my main root directory

*HOST_PATH=/Users/me/Desktop/myapp/myapp-reactnative/ios/Pods/../..

  • /Users/me/Desktop/myapp/myapp-reactnative/ios/Pods/../../node_modules/react-native-config/ios/ReactNativeConfig/BuildDotenvConfig.rb /Users/me/Desktop/myapp/myapp-reactnative/ios/Pods/../.. /Users/me/Desktop/myapp/myapp-reactnative/ios/Pods/../../node_modules/react-native-config/ios/ReactNativeConfig /Users/me/Desktop/myapp/myapp-reactnative/node_modules/react-native-config/ios/ReactNativeConfig/ReadDotEnv.rb:29:in read': Is a directory @ io_fread - /Users/me/Desktop/myapp/myapp-reactnative/.env (Errno::EISDIR) from /Users/me/Desktop/myapp/myapp-reactnative/node_modules/react-native-config/ios/ReactNativeConfig/ReadDotEnv.rb:29:in read_dot_env' from /Users/me/Desktop/myapp/myapp-reactnative/ios/Pods/../../node_modules/react-native-config/ios/ReactNativeConfig/BuildDotenvConfig.rb:15:in `' reading env file from /Users/me/Desktop/myapp/myapp-reactnative/ios/Pods/../.. and writing .m to /Users/me/Desktop/myapp/myapp-reactnative/ios/Pods/../../node_modules/react-native-config/ios/ReactNativeConfig going to read env file from root folder /Users/me/Desktop/myapp/myapp-reactnative/ios/Pods/../.. Command PhaseScriptExecution failed with a nonzero exit code*

So does anyone have any solution for this how to do it.

1 Answer 1

0
  • The react-native-config script is trying to read the .env file from the root directory of your project, but it's actually located in the .env folder.

  • You need to modify the BuildDotenvConfig.rb file in the react-native-config module.

  • Open the BuildDotenvConfig.rb file located in node_modules/react-native-config/ios/ReactNativeConfig.

  • Find the line that says env_file = File.join(host_path, '.env')

  • Modify it to env_file = File.join(host_path, '.env', '.env.env1')

  • This will tell the script to look for the .env.env1 file inside the .env folder.

  • Save the changes and try building your app again.

  • react-native-config example does not read variables from .env file or .env.prod #170 : https://github.com/lugg/react-native-config/issues/170

  • Environment Variables keeps reading from .env #652 : https://github.com/lugg/react-native-config/issues/652

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for reaching out, Below is the image link of my BuildDotenvConfig.rb file , i cannot find the line you mentioned i.postimg.cc/W30nscQ0/Screenshot-2024-03-16-135123.png
@ShubhamMore More The mentioned line is present in the ReadDotEnv.rb file, which is required by the BuildDotenvConfig.rb file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.