lugg / react-native-config

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

Xcode 10.2: Unable to spawn process (Exec format error) #342

Open bnolens opened 5 years ago

bnolens commented 5 years ago

Hi all,

I updated from Xcode 10.1 to Xcode 10.2 and got this error when building now error: unable to spawn process (Exec format error)

I've got a little build script executed during build that basically runs BuildDotenvConfig.ruby inside react-native-config/ios/ReactNativeConfig, to build the dotenv files. The error happens when this script is executing.

This is the script that runs during build:

#/bin/sh

RNCDIR="./node_modules/react-native-config/ios"

if [ ! -z "$SYMROOT" ]; then
  # Ensure directories exist before copying files
  mkdir -p $SYMROOT
  mkdir -p $BUILD_DIR

  # Build dotenv
  cd $RNCDIR
  ./ReactNativeConfig/BuildDotenvConfig.ruby
  cd -

  # Copy generated dotenv files to node_modules directory
  cp "$BUILD_DIR/GeneratedInfoPlistDotEnv.h" "$RNCDIR/ReactNativeConfig/GeneratedInfoPlistDotEnv.h"
  cp "$SYMROOT/GeneratedDotEnv.m" "$RNCDIR/ReactNativeConfig/GeneratedDotEnv.m"
fi

Does somebody know what this might be? I currently downgraded my Xcode version to 10.1 to fix this.

ohm89 commented 5 years ago

Hello everyone, I also have the same problem as @bnolens after upgrade Xcode to 10.2. The solution from @bnolens worked for me too.

But I doubt it would be how Xcode 10.2 interpret shell script to run on Mac OS. So if anyone who know how to change shell script follow to the right format, I am thank you in advance. (I'm sorry if I am misunderstanding this bug)

My Environment are

  1. react-native: 0.58.6
  2. react-native-config: 0.11.7

and I using cocoa-pod to build IOS applications.

stephenkopylov commented 5 years ago

Guys, just change the first line of scripts/build-env.sh from #/bin/sh to #!/bin/sh

bnolens commented 5 years ago

Changing the first line to #!/bin/sh fixed it for me. Thanks @stephenkopylov! 🍺

ohm89 commented 5 years ago

That's was fixed for me too. thank you @stephenkopylov 👍

benevbright commented 5 years ago

@stephenkopylov I love you man. I'm just curious. How do you know this stuff? What was the clue?

raphaelbadia commented 5 years ago

Where do you add the scripts/build-env.sh file ? The readme doesn't talk about it

bencergazda commented 5 years ago

@raphaelbadia Maybe https://github.com/luggit/react-native-config/issues/187#issuecomment-353156419?