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

[ios] error: unable to resolve product type 'com.apple.product-type.tool' for platform 'iphonesimulator' #27

Closed robbeman closed 1 year ago

robbeman commented 1 year ago

Trying to build the project for iOS and running in a simulator results in the following error:

CMake Error at /usr/local/Cellar/cmake/3.26.1/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /_project-path_/ios/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/dr-pogodin-react-native-static-server.build/pcre2/CMakeFiles/CMakeScratch/TryCompile-ImFDBO

    Run Build Command(s):/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project CMAKE_TRY_COMPILE.xcodeproj build -target cmTC_3c282 -parallelizeTargets -configuration Debug -hideShellScriptEnvironment && Command line invocation:
        /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project CMAKE_TRY_COMPILE.xcodeproj build -target cmTC_3c282 -parallelizeTargets -configuration Debug -hideShellScriptEnvironment

    User defaults from command line:
        HideShellScriptEnvironment = YES
        IDEPackageSupportUseBuiltinSCM = YES

    Build settings from command line:
        TOOLCHAINS = com.apple.dt.toolchain.XcodeDefault

    note: Using new build system
    note: Planning
    Analyze workspace

    Create build description
    Build description signature: 5340aba96d15030a4adfe747580e84dd
    Build description path: /_project-path_/ios/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/dr-pogodin-react-native-static-server.build/pcre2/CMakeFiles/CMakeScratch/TryCompile-ImFDBO/build/XCBuildData/5340aba96d15030a4adfe747580e84dd-desc.xcbuild

    note: Build preparation complete
    note: Building targets in parallel
    error: unable to resolve product type 'com.apple.product-type.tool' for platform 'iphonesimulator' (in target 'cmTC_3c282' from project 'CMAKE_TRY_COMPILE')
    error: unable to resolve product type 'com.apple.product-type.tool' for platform 'iphonesimulator' (in target 'cmTC_3c282' from project 'CMAKE_TRY_COMPILE')
    warning: ONLY_ACTIVE_ARCH=YES requested with multiple ARCHS and no active architecture could be computed; building for all applicable architectures (in target 'cmTC_3c282' from project 'CMAKE_TRY_COMPILE')
    warning: duplicate output file '/_project-path_/ios/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/dr-pogodin-react-native-static-server.build/pcre2/CMakeFiles/CMakeScratch/TryCompile-ImFDBO/Debug' on task: CreateUniversalBinary /_project-path_/ios/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/dr-pogodin-react-native-static-server.build/pcre2/CMakeFiles/CMakeScratch/TryCompile-ImFDBO/Debug normal arm64 x86_64 (in target 'cmTC_3c282' from project 'CMAKE_TRY_COMPILE')
    ** BUILD FAILED **

Which in turn triggers the error described in #18. I tried building with -DWITH_PCRE2=OFF but this does not seem to change the situation.

Looking at the exported vars I see

export PLATFORM_NAME\=iphonesimulator
export TARGET_DEVICE_PLATFORM_NAME\=iphonesimulator

which makes sense since I am actually building to a simulator target.

I am not sure if the library should inherit these settings from the main project, but I also can't seem to figure out how to prevent this.

birdofpreyru commented 1 year ago

Hey @robbeman , can try to clean-up artifacts from previous builds, and re-build it with the latest v0.7.4 (just released) version of the library?

robbeman commented 1 year ago

Hmm, no the problem seems to persist. (Removed ./ios/Pods and ./ios/Build, should be enough, right?) It may be that something is off with the surrounding project, because it does have some history.

Another thing I am wondering now is that I'm at a version of xcode that is a little old (13.1) which may cause some trouble? But can't update now because I have some disk-space shortage and would need a bit of a reorganise to accommodate for it. 😅

I don't have a strong background in this, so I'm at a bit of a loss for where to look. If you could use any info on the project config or some log outputs, please let me know.

birdofpreyru commented 1 year ago

Removed ./ios/Pods and ./ios/Build, should be enough, right?

Not sure; at least on my machine most of build artefacts hang out in /Users/<MY_USERNAME>/Library/Developer/Xcode/DerivedData. If you never heard of it, probably purging that folder will also help with freeing a bunch of disk space ;)

Also there is Product > Clean Build Folder option in Xcode to remove artifacts related to the project.

It may be that something is off with the surrounding project, because it does have some history.

If you are not sure is it a problem with the library, or with your app, perhaps you should start with trying whether the example app from this repo works for you?

I'm at a version of xcode that is a little old (13.1) which may cause some trouble?

No idea, but sounds a bit old. I am developing with the latest available 14.2; and it is already too old to build and deploy to my iPad under iPadOS 16.4 (updated OS in the last few days).

robbeman commented 1 year ago

The problem is also present in the example project. (For me.)

I'll try updating xcode.

robbeman commented 1 year ago

Okay, yesterday I managed to get past this error with a newer xcode version. So I guess that solves at least this issue.

Sorry for bothering and thank you for replying so swiftly. I'll disappear now. 👋