Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhaseScriptExecution failed for react-native-config on XCode build

I am trying to build my React Native project on Xcode and it is failing. The build target is react-native-config with the error: Run custom shell script '[CP-User] Config codegen' "Command PhaseScriptExecution failed with a nonzero exit code".

Trying to run it with --verbose, I get the following:

The following build commands failed: PhaseScriptExecution [CP-User]\ Config\ codegen /User/userName/Library/Developer/Xcode/DerivedData/projectName/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-config-build/Script-21BEEA33BD6A21BF27B73D38DC1AD4.sh

I am running React Native 0.63.1 with React-Native-Config 1.4.1 and I have tried reinstalling node_modules, pods, deleting DerivedData and cleaning the build but no luck. I also do not see any references to react-native-config under Build Phases > Run Script.

Any ideas how to solve this?

like image 954
zosozo Avatar asked Dec 04 '20 21:12

zosozo


3 Answers

Usually this problem when a dependency is not updated.

You can try the following steps:

1-) cd ios
2-) rm -rf Podfile.lock
3-) rm -rf Pods
4-) delete .xcworkspace
5-) pod install
like image 169
Mohamad El-Mordaa Avatar answered Oct 19 '22 01:10

Mohamad El-Mordaa


Usually, this is caused by a badly formatted .env file. Double-check your .env.

like image 12
karlmarxlopez Avatar answered Oct 19 '22 02:10

karlmarxlopez


I had the same Problem, I followed a tutorial to build ios, it is pretty old (one year) in tutorial I added code which include some thing like

post_install do |installer|
installer.pods_project.targets.each do |target|
  if target.name == 'React'
  target.remove_from_project
  end
  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'\
    '&& export BUILD_DIR=$RNC_ROOT/ios/ReactNativeConfig'\
    '&& ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.ruby'
    target.build_phases << phase
    target.build_phases.move(phase,0)
  end
 end
end

please delete it from podfile and follow the doc of react-native-config to use environment variables here after delete dont forget pod install

while building take care of build scheme (which one are you using while build time)

like image 4
M_Badrah Avatar answered Oct 19 '22 01:10

M_Badrah