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

CMake v3.30.0 is not supported. Compatibility with future CMake versions is to be verified. #111

Open harrymash2006 opened 1 month ago

harrymash2006 commented 1 month ago

const prepareAssets = async () => { try { const fileDir = resolveAssetsPath('webroot'); const filePath = fileDir + '/index.html'; if (Platform.OS === 'ios') { await modifyContent(filePath); } if (Platform.OS === 'android') { console.log('fileDir:: inside android::', fileDir); const alreadyExtracted = await exists(fileDir); console.log('fileDir:: alreadyExtracted::', alreadyExtracted); if (alreadyExtracted) { await unlink(fileDir); } console.log('fileDir:: before copy assets::'); await copyFileAssets('webroot', fileDir); console.log('fileDir:: before read file::'); await modifyContent(filePath); } return fileDir; } catch (e) { console.log('fileDir:: exception::', e); } return null; };

Please help.

birdofpreyru commented 1 month ago

It reads like you failed to follow README and correctly bundle in the webroot asset folder you are trying to access. In addition to README the repo contains Example App demonstrating how to do it correctly.

harrymash2006 commented 1 month ago

Hi @birdofpreyru I followed the same instructions and did the same code as the example app but I am getting the same issues. I ended up using a document directory thing and writing things manually to that path and then using that path for the server and got it working.

I am facing some other issue that is unrelated to this but when I try to build the app after selecting "Any iOS Device (arm64)" option I get the following error:

CMake Error at /opt/homebrew/Cellar/cmake/3.30.0/share/cmake/Modules/CMakeDetermineCompilerABI.cmake:129 (message):
  The C compiler targets architectures:

    "arm64"

  but CMAKE_OSX_ARCHITECTURES is

    "arm64;x86_64"

Call Stack (most recent call first):
  /opt/homebrew/Cellar/cmake/3.30.0/share/cmake/Modules/CMakeTestCCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)
  CMakeLists.txt:109 (project)

-- Configuring incomplete, errors occurred!
CMake Error at CMakeLists.txt:72 (execute_process):
  execute_process failed command indexes:

    1: "Child return code: 1"

can you please help @birdofpreyru?

thanks, I really appreciate it.

birdofpreyru commented 1 month ago

Does the Example app build for you?

harrymash2006 commented 1 month ago

No, actually I am getting some different errors when running sample app on simulator.

My app works fine on simulator but I get this error when I try to run it on a real device or try to build for publishing for the store which uses only arm64, where CMAKE_OSX_ARCHITECTURES expects architecture "arm64;x86_64"

birdofpreyru commented 1 month ago

No, actually I am getting some different errors when running sample app on simulator.

What errors do you get when running the sample app?

_My app works fine on simulator but I get this error when I try to run it on a real device or try to build for publishing for the store which uses only arm64, where CMAKE_OSX_ARCHITECTURES expects architecture "arm64;x8664"

Any errors in your app, which aren't present in the Example App, are your problems to solve — I am not going to do your development work for you for free.

harrymash2006 commented 1 month ago
Screenshot 2024-07-10 at 4 36 20 PM

I am getting the above error in the sample app as well, when I try to run the app on a real device.

harrymash2006 commented 1 month ago

Hi @birdofpreyru any update on the above?

birdofpreyru commented 1 month ago

Do you get this error when building the Example app?

harrymash2006 commented 1 month ago

yes Thanks, Hardik Mashru Expert Mobile Developer | React Native, Android, iOS, Flutter, Java, J2EE, Restful Web Services, Core PHP, Struts, Hibernate

On Wed, Jul 10, 2024 at 6:04 PM Dr. Sergey Pogodin @.***> wrote:

Do you get this error when building the Example app?

— Reply to this email directly, view it on GitHub https://github.com/birdofpreyru/react-native-static-server/issues/111#issuecomment-2220398101, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNOPDAB6CBYLUP2L4XTL7DZLUS4PAVCNFSM6AAAAABKTJMSCGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRQGM4TQMJQGE . You are receiving this because you authored the thread.Message ID: @.***>

birdofpreyru commented 1 month ago

Ok, I’ll re-recheck example app build for iOS when I find time.

birdofpreyru commented 1 month ago

Though, are you trying to build it for Android on macOS host machine?

harrymash2006 commented 1 month ago

Android build is working fine, only having issues with iOS. I am trying on macOS machine.

martinezleoml commented 1 month ago

We're also facing the issue, it sounds like a regression bug with the latest CMake version (3.30) & Xcode builds: https://gitlab.kitware.com/cmake/cmake/-/issues/26128

Downgrading to CMake 3.29.6 solves the issue. ;)

birdofpreyru commented 1 month ago

Yes, it seems to be a regression in CMake 3.30.0:

birdofpreyru commented 1 month ago

Ok, starting with v0.15.1 this library will refuse to be built with CMake v3.30.0 on all platforms, with a clear error message pointing back to this issue.

l keep this issue ticket open, and marked as In Progress and On Hold, to remind myself to check back if the issue is resolved in future CMake versions.

birdofpreyru commented 4 weeks ago

Heads-up: it seems to be still broken with CMake v3.30.1; and, presumably, it is aimed to be fixed in CMake v3.30.2.

niryuu commented 2 weeks ago

This is reproduced on CMake v3.30.2 installed via Homebrew.

niryuu commented 2 weeks ago

I do not know well about CMake, and why we need ESCAPED_ARCHS, but modifying CMakeLists.txt as below works. from -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_ARCHS} to -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} Environment: macOS 14.3.1 XCode 15.4.0 CMake v3.30.2

birdofpreyru commented 2 weeks ago

Yeah, as the CMake ticket is closed now, I guess we need some corrections in our CMakeLists.txt.

_why we need ESCAPED_ARCHS_

as the comment says, without an escape of ; CMake replaced it by a whitespace when EXTRA_BUILD_ARGS was added to the COMMAND piece of execute_process(), thus effectively the command was run with -DCMAKE_OSX_ARCHITECTURES=arm64 x86_64 instead of -DCMAKE_OSX_ARCHITECTURES=arm64;x86_64, which resulted in PCRE2 built only for the first arch in the list, rather than for each one, and an error down the line when the built failed to link against PCRE2 built for the target architecture.

So, although the change you did seemingly worked, you really want to verify for what architectures PCRE2 library got built, and perhaps a different change is needed. I am not an expert in CMake either, though, so can't give much help, until I find a moment to dive into it myself.