birdofpreyru / react-native-static-server

Embedded HTTP server for React Native
https://dr.pogodin.studio/docs/react-native-static-server
Other
154 stars 22 forks source link

PhaseScriptExecution FAILED on iOS Build #33

Closed frederiko-famobi closed 1 year ago

frederiko-famobi commented 1 year ago

While trying to build the version 0.7.9 on iOS, the following error appears:

▸ ** ARCHIVE FAILED **
▸ The following build commands failed:
▸   PhaseScriptExecution [CP-User]\ Build\ native\ dependencies /Users/expo/Library/Developer/Xcode/DerivedData/APP-epnliplejavjuvczkxfzgbxaosev/Build/Intermediates.noindex/ArchiveIntermediates/APP/IntermediateBuildFilesPath/Pods.build/Debug-iphoneos/dr-pogodin-react-native-static-server.build/Script-46EB2E00026A10.sh (in target 'dr-pogodin-react-native-static-server' from project 'Pods')
▸ (1 failure)
** ARCHIVE FAILED **
The following build commands failed:
    PhaseScriptExecution [CP-User]\ Build\ native\ dependencies /Users/expo/Library/Developer/Xcode/DerivedData/APP-epnliplejavjuvczkxfzgbxaosev/Build/Intermediates.noindex/ArchiveIntermediates/APP/IntermediateBuildFilesPath/Pods.build/Debug-iphoneos/dr-pogodin-react-native-static-server.build/Script-46EB2E00026A10.sh (in target 'dr-pogodin-react-native-static-server' from project 'Pods')
(1 failure)
Exit status: 65

I ran pod install and installed cmake while building with EAS Build.

Is there any reason why this error is happening?

birdofpreyru commented 1 year ago

I don't know @frederiko-famobi , was it working for you before with previous library versions? Do you know at what version it broke? I guess, if you run the build & run without archiving, you should be able to see more info regarding the failed build step. Then, if it is an issue with EAS Build per se, we have #19 open, and on hold, because I don't officially support Expo yet; and if it is an issue with CMake detection, then we have #29 open, and on hold, because from all inputs I got on it so far, and what I see on my machine, I don't understand why ppl having such problem, and somebody should help explaining me it. And if it is a new issue, then let's discuss it further here.

exotexot commented 1 year ago

Must be an expo thing. Building, archiving and submission to AppStore works fine for me on iOS.

frederiko-famobi commented 1 year ago

Thanks for the reply @birdofpreyru and @exotexot, I will try to build locally and will let you know if the problem persists. I am documenting every step for the Expo installation so I can contribute to the documentation of the library as soon as it's working fine.

frederiko-famobi commented 1 year ago

A quick update: the reason why this error occurs was because of the cmake installation on EAS Build.

I had to change some config and this is how it should be done:

First I created a eas build pre install script, and add it on my package.json scripts:

  "scripts": {
    "eas-build-pre-install": "./pre-install",
    ...

And added the script file pre-install to my root folder with the following content:

 #!/usr/bin/env bash

# This script will follow the script eas-build-pre-install located in package.json and will be executed before EAS Build runs npm install on the EAS Build platform.
echo "running pre install..."

if [[ "$EAS_BUILD_PLATFORM" == "android" ]]; then
  sudo apt-get install --yes cmake
elif [[ "$EAS_BUILD_PLATFORM" == "ios" ]]; then
  HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake
fi

Also run: chmod 755 pre-install so the file can run on Expo servers.

And then, when running eas build, it will execute an extra step called "Pre-install Hook". I also had to run the expo prebuild in my project so I expose the ios and android folders to modify it as required by the library.

So the EAS Build will skip the step Prebuild and use my local files depending on the platform.

I tested the local build and it was working fine too, with: eas build --platform ios --local

I can now build on EAS for both iOS and Android. Maybe it also solves #19.

Thank you and soon I will be adding all of this information and other ones to guide other users that wants to use Expo / EAS Build with this library in their projects.