birdofpreyru / react-native-static-server

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

IOs build fail #84

Closed VaiteaBimOne closed 9 months ago

VaiteaBimOne commented 9 months ago

Hi! When building my ios app on appcenter I have issues similar to #76 and #67. I added a pre-build script to reinstall cmake and pkg-config and check the install path. I saw in a couple of thread the issue with Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) but my path in my pre-build matches the one in the error. Do you have an idea where the issue might come from? Thanks!

The error message is

The following build commands failed:
PhaseScriptExecution [CP-User]\ Build\ native\ dependencies /Users/runner/Library/Developer/Xcode/DerivedData/BIMTrack-derkunmxtvstcdbaddnbgkfypyjz/Build/Intermediates.noindex/ArchiveIntermediates/BIMTrackInternal/IntermediateBuildFilesPath/Pods.build/Internal-iphoneos/dr-pogodin-react-native-static-server.build/Script-46EB2E00026FA0.sh (in target 'dr-pogodin-react-native-static-server' from project 'Pods')

with this error in the logs

** BUILD SUCCEEDED **
 -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
    Reason given by package: The command
       "/usr/local/bin/pkg-config" --libs-only-l --version
     failed with output:

     stderr: 
       Ignoring incompatible output option "--version"
    Must specify package names on the command line
    result: 
 1

As a pre-build script I added this

which brew && echo "Homebrew found" || echo "Homebrew NOT found"
brew reinstall cmake pkg-config
which cmake
which pkg-config

and have this result

/usr/local/bin/brew
Homebrew found
... [reinstall]
/usr/local/bin/cmake
/usr/local/bin/pkg-config

The path looks the same in the pre-build but I still have the error.

VaiteaBimOne commented 9 months ago

I just did a release test and it's building as release

Command line invocation:
 /Applications/Xcode_14.1.app/Contents/Developer/usr/bin/xcodebuild -workspace /Users/runner/work/1/s/ios/BIMTrack.xcworkspace -scheme BIMTrackProduction archive -archivePath /Users/runner/work/1/output/build/archive/BIMTrackProduction CODE_SIGN_STYLE=Manual

but not internal

Command line invocation:
/Applications/Xcode_14.1.app/Contents/Developer/usr/bin/xcodebuild -workspace /Users/runner/work/1/s/ios/BIMTrack.xcworkspace -scheme BIMTrackInternal archive -archivePath /Users/runner/work/1/output/build/archive/BIMTrackInternal CODE_SIGN_STYLE=Manual

The logs are the same until I have this message for the internal build

warning: Run script build phase 'Start Packager' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'BIMTrack' from project 'BIMTrack')
2023-11-02T15:13:11.7134400Z warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'BIMTrack' from project 'BIMTrack')
2023-11-02T15:13:11.7138020Z warning: Run script build phase 'Bundle React Native code and images' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'BIMTrack' from project 'BIMTrack')
2023-11-02T15:13:11.7141930Z warning: Run script build phase '[CP-User] Config codegen' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'react-native-config' from project 'Pods')
2023-11-02T15:13:11.7144140Z ** ARCHIVE FAILED **
birdofpreyru commented 9 months ago

Hey @VaiteaBimOne ,

Yeah... I remember I've encountered this very error myself, but I am not sure I remember the exact details correctly.

However, I believe this

** BUILD SUCCEEDED **
 -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
    Reason given by package: The command
       "/usr/local/bin/pkg-config" --libs-only-l --version
     failed with output:

     stderr: 
       Ignoring incompatible output option "--version"
    Must specify package names on the command line
    result: 
 1

actually happens because there was intended to be some other command in the script exactly in-between --lib-only-l and --version, and think perhaps it was the path to NodeJS executable (i.e. --version argument was actually intended to Node, rather than to the pkg-config), which could not be found in my case because it was installed via NVM, and the fix for me was to edit /ios/.xcode.env to have there:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

export NODE_BINARY=$(command -v node)

I know, this kind of reads weird, why Node executable would be in that place... but that's exactly how I remember it, that this error was very misleading, when I figured it out.

Will you investigate, if something along these lines helps?

VaiteaBimOne commented 9 months ago

Hi @birdofpreyru. Thanks for the quick response.

I tried to update my xcode.env but unfortunately, the build failed with no changes in the logs and the PkgConfig issue is still there.

birdofpreyru commented 9 months ago

Maybe fixed in v0.9.1 release. Please, tell if it works for you.

VaiteaBimOne commented 9 months ago

Hi @birdofpreyru Sorry for the delay!

I took some time to test the 9.1.0 version and the warning for PKG_CONFIG_EXECUTABLE seems to have disappear from the logs.

I now have the error

 The following build commands failed:
2023-11-13T16:47:11.9273310Z    PhaseScriptExecution [CP-User]\ Build\ native\ dependencies /Users/runner/Library/Developer/Xcode/DerivedData/BIMTrack-derkunmxtvstcdbaddnbgkfypyjz/Build/Intermediates.noindex/ArchiveIntermediates/BIMTrackInternal/IntermediateBuildFilesPath/Pods.build/Internal-iphoneos/dr-pogodin-react-native-static-server.build/Script-46EB2E00026FE0.sh (in target 'dr-pogodin-react-native-static-server' from project 'Pods')

I didn't see any error at that step be here are the complete logs. 18_Xcode build (signed).txt

I saw your deleted message about having pcre2 installed. I check to be sure and have it installed pcre2 10.42 is already installed and up-to-date

Thanks!

birdofpreyru commented 9 months ago

Ok @VaiteaBimOne , I had a brief look at your log, actually the bulk of the build passes fine now, the problem is it messes up with paths at the very last step when it copies build outputs into products directory (line 23359). The copy happens here and the problem is that the script assumes CONFIGURATION variable is equal either Debug or Release (then it will work fine), but in your build it equals Internal. When that Internal value is fed as --config parameter into lighttpd build (here) it is ignored (I guess as an unknown configuration), and lighttpd is build with Debug config, into a folder named like that, while the copy command below expects it to be built into Internal-... folder.

Hopefully, I'll fix it in the next version.

VaiteaBimOne commented 9 months ago

Thanks a lot for looking a it!

VaiteaBimOne commented 9 months ago

@birdofpreyru Hi! I just wanted to tell you that 0.9.2 is working well with the fix.

Thanks again! :)