birdofpreyru / react-native-static-server

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

macOS / try a different cmake path linking option (`~/.zshenv`) #119

Closed smellman closed 1 month ago

smellman commented 1 month ago

I try to install react-native-static-server with Xcode 16 but compile process fails.

Error message

dr-pogodin-react-native-static-server
Command PhaseScriptExecution failed with a nonzero exit code

Environment

How to produce

git clone git@github.com:birdofpreyru/react-native-static-server.git
cd react-native-static-server
yarn install
git submodule update --init --recursive
cd example/ios
RCT_NEW_ARCH_ENABLED=1 pod install
open ReactNativeStaticServerExample.xcworkspace # and modify signing
cd ..
yarn run start

Then build ReactNativeStaticServerExample.xcworkspace in Xcode 16.

Screenshot

スクリーンショット 2024-09-25 7 44 05
smellman commented 1 month ago

I find the reason in build logs:


Showing Recent Issues
/Users/btm/Library/Developer/Xcode/DerivedData/ReactNativeStaticServerExample-bfykmthjwnsxjgbupqlplkyggffn/Build/Intermediates.noindex/Pods.build/Custom-iphoneos/dr-pogodin-react-native-static-server.build/Script-46EB2E00019E00.sh: line 21: cmake: command not found

I installed cmake with Homebrew but not in /usr/bin. So, my workaround is following:

--- a/dr-pogodin-react-native-static-server.podspec
+++ b/dr-pogodin-react-native-static-server.podspec
@@ -59,6 +59,8 @@ Pod::Spec.new do |s|
     :script => <<-CMD
       set -e

+      export PATH="/opt/homebrew/bin:$PATH"
+
       if [[ ${CONFIGURATION} == "Debug" ]]
       then
         LIGHTTPD_CONFIG="Debug"
birdofpreyru commented 1 month ago

@smellman actually, library README mentions that on macOS cmake and pkg-config should be simlinked into /usr/local/bin for Xcode scripts to be able to find them:

sudo ln -s $(which cmake) /usr/local/bin/cmake
sudo ln -s $(which pkg-config) /usr/local/bin/pkg-config

another (better option, but I haven't tried) is to add eval "$(/opt/homebrew/bin/brew shellenv)"' into ~/.zshenv — Homebrew adds that command, which injects its path into PATH, to ~/.zshrc or ~/.zprofile, which aren't sourced into Xcode environment, but from what I read on Internet ~/.zshenv is supposed to be sourced into all interactive and non-interactive terminals... though I haven't tried it myself yet.

P.S.: I'll keep this ticket open, to actually try this ~/.zshenv option, and update README accordingly, if it works.

smellman commented 1 month ago

I tried ~/.zshenv but it doesn't work because script_phase output #!/bin/sh.

So, I need add symbolic links into /usr/local/bin. Thanks!