Skip to content

Document how to specify minimum versions for target platforms, and provide sensible defaults #174

Open

Description

@shirakaba

For a quick check, I tried process.dlopen to run the existing macOS slice in Node.js, but I got an error that it was built for macOS 15.2, which is newer than my running OS.

Image

This brings to my attention that we will need to document how to configure minimum versions in cmake, and provide sensible defaults for all platforms. At present, it doesn't seem like it's configured at all. Ideally, it should track the minimum versions used by react-native, react-native-macos, etc.

Activity

  1. kraenhansen commented on Oct 24, 2025

    @kraenhansen
    Collaborator

    This should be configurable (and we should document that) by setting the CMAKE_OSX_DEPLOYMENT_TARGET variable. Either in your project's CMake configuration or since #239 by passing -D CMAKE_OSX_DEPLOYMENT_TARGET=15.2 when calling cmake-rn.

    For discoverability and ease of use, we might want to add an option (--minimum-apple-target?) to cmake-rn similar to the --android-sdk-version we already have for Android:

    const androidSdkVersionOption = new Option(
    "--android-sdk-version <version>",
    "The Android SDK version to use for Android builds",
    ).default(DEFAULT_ANDROID_SDK_VERSION);

  2. shirakaba commented on Oct 24, 2025

    @shirakaba
    CollaboratorAuthor

    When I read --minimum-apple-target, I am unclear what number I should put in when developing for both iOS and macOS.

    Ultimately, CMAKE_OSX_DEPLOYMENT_TARGET is treated like this:

    macro(__apple_compiler_clang lang)
      # ...
    
      set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
    
      # ...
    
      if(_CMAKE_OSX_SYSROOT_PATH MATCHES "/iPhoneOS")
        set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-miphoneos-version-min=")
      elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/iPhoneSimulator")
        set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mios-simulator-version-min=")
      elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/AppleTVOS")
        set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mtvos-version-min=")
      elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/AppleTVSimulator")
        set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mtvos-simulator-version-min=")
      elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/XROS")
        set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "--target=<ARCH>-apple-xros<VERSION_MIN>")
      elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/XRSimulator")
        set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "--target=<ARCH>-apple-xros<VERSION_MIN>-simulator")
      elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/WatchOS")
        set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mwatchos-version-min=")
      elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/WatchSimulator")
        set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mwatchos-simulator-version-min=")
      elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/MacOSX" AND CMAKE_SYSTEM_NAME STREQUAL "iOS")
        set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "--target=<ARCH>-apple-ios<VERSION_MIN>-macabi")
      else()
        set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
      endif()
    endmacro()

    So generally, it's setting the version-min for the OS, but in some cases it's setting the target. This doesn't get me any closer to a better name than --minimum-apple-target, though. I guess all we can do is pick a name for the flag and just support it adequately with documentation, especially for the odd cases like macOS and Catalyst.


    In case it comes up, here is how I handled CMAKE_OSX_DEPLOYMENT_TARGET for the very odd case of Catalyst (which brings the "is it iOS or OS X" question).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CMake RNOur `cmake` wrapping CLIdocumentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions