diff --git a/.github/workflows/build-hermes-macos-spm.yml b/.github/workflows/build-hermes-macos-spm.yml new file mode 100644 index 00000000000000..0a4d703ef9cfc8 --- /dev/null +++ b/.github/workflows/build-hermes-macos-spm.yml @@ -0,0 +1,148 @@ +name: Build Hermes for macOS SPM + +on: + workflow_call: + outputs: + hermes-version: + description: "The version of Hermes that was built" + value: ${{ jobs.prepare_hermes_workspace.outputs.hermes-version }} + react-native-version: + description: "The version of React Native" + value: ${{ jobs.prepare_hermes_workspace.outputs.react-native-version }} + +jobs: + prepare_hermes_workspace: + runs-on: ubuntu-latest + env: + HERMES_WS_DIR: /tmp/hermes + HERMES_VERSION_FILE: packages/react-native/sdks/.hermesversion + # Use the Hermes commit at the merge base with facebook/react-native + HERMES_COMMIT: e0fc67142ec0763c6b6153ca2bf96df815539782 + outputs: + react-native-version: ${{ steps.prepare-hermes-workspace.outputs.react-native-version }} + hermes-version: ${{ steps.prepare-hermes-workspace.outputs.hermes-version }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup toolchain + uses: ./.github/actions/microsoft-setup-toolchain + with: + node-version: '22' + cache-npm-dependencies: '' + - name: Install dependencies + run: yarn install + - name: Prepare Hermes Workspace + id: prepare-hermes-workspace + uses: ./.github/actions/prepare-hermes-workspace + with: + hermes-ws-dir: ${{ env.HERMES_WS_DIR }} + hermes-version-file: ${{ env.HERMES_VERSION_FILE }} + + build_hermesc_apple: + runs-on: macos-14 + needs: prepare_hermes_workspace + env: + HERMES_WS_DIR: /tmp/hermes + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Build HermesC Apple + uses: ./.github/actions/build-hermesc-apple + with: + hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} + react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} + + build_macos_slice: + runs-on: macos-14 + needs: [build_hermesc_apple, prepare_hermes_workspace] + env: + HERMES_WS_DIR: /tmp/hermes + HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin + HERMES_OSXBIN_ARTIFACTS_DIR: /tmp/hermes/osx-bin + MAC_DEPLOYMENT_TARGET: "10.15" + strategy: + fail-fast: false + matrix: + flavor: [Debug, Release] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Build macOS Slice + uses: ./.github/actions/build-apple-slices-hermes + with: + flavor: ${{ matrix.flavor }} + slice: macosx + hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} + react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} + + package_hermes_macos: + runs-on: macos-14 + needs: [build_macos_slice, prepare_hermes_workspace] + env: + HERMES_WS_DIR: /tmp/hermes + HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin + strategy: + fail-fast: false + matrix: + flavor: [Debug, Release] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup toolchain + uses: ./.github/actions/microsoft-setup-toolchain + with: + platform: macos + node-version: '22' + - name: Download macOS slice + uses: actions/download-artifact@v4 + with: + name: slice-macosx-${{ matrix.flavor }} + path: ./packages/react-native/sdks/hermes/ + - name: Unzip slice + shell: bash + run: | + cd ./packages/react-native/sdks/hermes + tar -xzv -f build_macosx_${{ matrix.flavor }}.tar.gz + mv build_macosx_${{ matrix.flavor }} build_macosx + - name: Prepare destroot folder + shell: bash + run: | + cd ./packages/react-native/sdks/hermes || exit 1 + chmod +x ./utils/build-apple-framework.sh + . ./utils/build-apple-framework.sh + prepare_dest_root_for_ci + - name: Create framework for macOS + shell: bash + run: | + cd ./packages/react-native/sdks/hermes || exit 1 + echo "[HERMES] Creating the macOS framework" + chmod +x ./utils/build-ios-framework.sh + # Only build for macOS, not the full iOS framework + ./utils/build-ios-framework.sh build_framework + chmod +x ./destroot/bin/hermesc + - name: Package Hermes macOS tarball + shell: bash + run: | + BUILD_TYPE="${{ matrix.flavor }}" + echo "Packaging Hermes for macOS $BUILD_TYPE build type" + + TARBALL_OUTPUT_DIR=$(mktemp -d /tmp/hermes-tarball-output-XXXXXXXX) + + TARBALL_FILENAME=$(node ./packages/react-native/scripts/hermes/get-tarball-name.js --buildType "$BUILD_TYPE") + + TARBALL_OUTPUT_PATH=$(node ./packages/react-native/scripts/hermes/create-tarball.js \ + --inputDir ./packages/react-native/sdks/hermes \ + --buildType "$BUILD_TYPE" \ + --outputDir $TARBALL_OUTPUT_DIR) + + echo "Hermes tarball saved to $TARBALL_OUTPUT_PATH" + + mkdir -p $HERMES_TARBALL_ARTIFACTS_DIR + cp $TARBALL_OUTPUT_PATH $HERMES_TARBALL_ARTIFACTS_DIR/. + + ls -lh $HERMES_TARBALL_ARTIFACTS_DIR + - name: Upload Hermes tarball + uses: actions/upload-artifact@v4.3.4 + with: + name: hermes-darwin-bin-${{ matrix.flavor }} + path: /tmp/hermes/hermes-runtime-darwin/hermes-ios-${{ matrix.flavor }}.tar.gz diff --git a/.github/workflows/build-react-native-dependencies-pr.yml b/.github/workflows/build-react-native-dependencies-pr.yml new file mode 100644 index 00000000000000..17dfd5d056f6fe --- /dev/null +++ b/.github/workflows/build-react-native-dependencies-pr.yml @@ -0,0 +1,155 @@ +name: Build ReactNativeDependencies for PR + +on: + workflow_call: + +jobs: + prepare_workspace: + name: Prepare workspace + runs-on: macos-14 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup toolchain + uses: ./.github/actions/microsoft-setup-toolchain + with: + platform: macos + node-version: '22' + - name: Install dependencies + run: yarn install + - name: Restore cache if present + id: restore-rn-deps + uses: actions/cache/restore@v4 + with: + path: packages/react-native/third-party/ + key: v2-pr-rn-dependencies-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js') }} + enableCrossOsArchive: true + - name: Prepare Dependencies + if: steps.restore-rn-deps.outputs.cache-hit != 'true' + run: | + node scripts/releases/prepare-ios-prebuilds.js -s + - name: Generate Package.swift + if: steps.restore-rn-deps.outputs.cache-hit != 'true' + run: | + node scripts/releases/prepare-ios-prebuilds.js -w + - name: Upload Artifacts + uses: actions/upload-artifact@v4.3.4 + with: + name: rn-deps-workspace + path: packages/react-native/third-party/ + - name: Save Cache + uses: actions/cache/save@v4 + if: ${{ github.ref == 'refs/heads/main' }} + with: + key: v2-pr-rn-dependencies-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js') }} + enableCrossOsArchive: true + path: packages/react-native/third-party/ + + build-macos-slice: + name: Build macOS Slice + runs-on: macos-14 + needs: [prepare_workspace] + strategy: + fail-fast: false + matrix: + flavor: ['Debug', 'Release'] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup toolchain + uses: ./.github/actions/microsoft-setup-toolchain + with: + platform: macos + node-version: '22' + - name: Install dependencies + run: yarn install + - name: Restore slice folder + id: restore-slice-folder + uses: actions/cache/restore@v4 + with: + path: packages/react-native/third-party/.build/Build/Products + key: v2-pr-rn-dependencies-slice-macos-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js') }} + - name: Restore workspace + if: steps.restore-slice-folder.outputs.cache-hit != 'true' + uses: actions/download-artifact@v4 + with: + name: rn-deps-workspace + path: packages/react-native/third-party/ + - name: Print third-party folder structure + run: ls -lR packages/react-native/third-party + - name: Build slice for macOS ${{ matrix.flavor }} + if: steps.restore-slice-folder.outputs.cache-hit != 'true' + run: node scripts/releases/prepare-ios-prebuilds.js -b -p macos -r ${{ matrix.flavor }} + - name: Upload Artifacts + uses: actions/upload-artifact@v4.3.4 + with: + name: prebuild-slice-${{ matrix.flavor }}-macos + path: | + packages/react-native/third-party/.build/Build/Products + - name: Save Cache + uses: actions/cache/save@v4 + if: ${{ github.ref == 'refs/heads/main' }} + with: + key: v2-pr-rn-dependencies-slice-macos-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js') }} + enableCrossOsArchive: true + path: | + packages/react-native/third-party/.build/Build/Products + + create-xcframework: + name: Create XCFramework + runs-on: macos-14 + needs: [build-macos-slice] + strategy: + fail-fast: false + matrix: + flavor: [Debug, Release] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup toolchain + uses: ./.github/actions/microsoft-setup-toolchain + with: + platform: macos + node-version: '22' + - name: Install dependencies + run: yarn install + - name: Restore XCFramework + id: restore-xcframework + uses: actions/cache/restore@v4 + with: + path: | + packages/react-native/third-party/ + key: v2-pr-rn-dependencies-xcframework-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js') }} + - name: Restore workspace + if: steps.restore-xcframework.outputs.cache-hit != 'true' + uses: actions/download-artifact@v4 + with: + name: rn-deps-workspace + path: packages/react-native/third-party/ + - name: Download slices + if: steps.restore-xcframework.outputs.cache-hit != 'true' + uses: actions/download-artifact@v4 + with: + pattern: prebuild-slice-${{ matrix.flavor }}-* + path: packages/react-native/third-party/.build/Build/Products + merge-multiple: true + - name: Create XCFramework (unsigned) + if: steps.restore-xcframework.outputs.cache-hit != 'true' + run: node scripts/releases/prepare-ios-prebuilds.js -c -r ${{ matrix.flavor }} + - name: Compress and Rename XCFramework + if: steps.restore-xcframework.outputs.cache-hit != 'true' + run: | + tar -cz -f packages/react-native/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz \ + packages/react-native/third-party/ReactNativeDependencies.xcframework + - name: Upload XCFramework Artifact + uses: actions/upload-artifact@v4 + with: + name: ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz + path: packages/react-native/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz + - name: Save XCFramework in Cache + if: ${{ github.ref == 'refs/heads/main' }} + uses: actions/cache/save@v4 + with: + path: | + packages/react-native/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz + key: v2-pr-rn-dependencies-xcframework-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js') }} diff --git a/.github/workflows/microsoft-pr.yml b/.github/workflows/microsoft-pr.yml index 2c1b4500b3ccf4..8a432f13070937 100644 --- a/.github/workflows/microsoft-pr.yml +++ b/.github/workflows/microsoft-pr.yml @@ -132,6 +132,22 @@ jobs: permissions: {} uses: ./.github/workflows/microsoft-build-rntester.yml + build-hermes-macos: + name: "Build Hermes for macOS" + permissions: {} + uses: ./.github/workflows/build-hermes-macos-spm.yml + + build-react-native-dependencies: + name: "Build ReactNativeDependencies" + permissions: {} + uses: ./.github/workflows/build-react-native-dependencies-pr.yml + + build-spm-macos: + name: "Build SPM macOS" + permissions: {} + needs: [build-hermes-macos, build-react-native-dependencies] + uses: ./.github/workflows/prebuild-macos-core.yml + # https://github.com/microsoft/react-native-macos/issues/2344 # Disable these tests because verdaccio hangs # test-react-native-macos-init: @@ -158,6 +174,7 @@ jobs: - yarn-constraints - javascript-tests - build-rntester + - build-spm-macos # - test-react-native-macos-init # - react-native-test-app-integration steps: diff --git a/.github/workflows/prebuild-macos-core.yml b/.github/workflows/prebuild-macos-core.yml new file mode 100644 index 00000000000000..d25015a0856c5d --- /dev/null +++ b/.github/workflows/prebuild-macos-core.yml @@ -0,0 +1,205 @@ +name: Prebuild macOS Dependencies + +on: + workflow_call: # this directive allow us to call this workflow from other workflows + + +jobs: + build-rn-slice: + runs-on: macos-14 + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + flavor: ['Debug', 'Release'] + slice: ['macos'] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Restore cache if present + id: restore-macos-slice + uses: actions/cache/restore@v4 + with: + key: v1-macos-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }} + path: packages/react-native/ + - name: Setup toolchain + if: steps.restore-macos-slice.outputs.cache-hit != 'true' + uses: ./.github/actions/microsoft-setup-toolchain + with: + platform: macos + node-version: '22' + xcode-developer-dir: '/Applications/Xcode_16.2.0.app' + - name: Yarn Install + if: steps.restore-macos-slice.outputs.cache-hit != 'true' + run: yarn install + shell: bash + - name: Download Hermes + if: steps.restore-macos-slice.outputs.cache-hit != 'true' + continue-on-error: true + uses: actions/download-artifact@v4 + with: + name: hermes-darwin-bin-${{ matrix.flavor }} + path: /tmp/hermes/hermes-runtime-darwin + - name: Extract Hermes + if: steps.restore-macos-slice.outputs.cache-hit != 'true' + shell: bash + run: | + HERMES_TARBALL_ARTIFACTS_DIR=/tmp/hermes/hermes-runtime-darwin + if [ ! -d $HERMES_TARBALL_ARTIFACTS_DIR ]; then + echo "Hermes tarball artifacts dir not present ($HERMES_TARBALL_ARTIFACTS_DIR)." + exit 0 + fi + + TARBALL_FILENAME=$(node ./packages/react-native/scripts/hermes/get-tarball-name.js --buildType "${{ matrix.flavor }}") + TARBALL_PATH=$HERMES_TARBALL_ARTIFACTS_DIR/$TARBALL_FILENAME + + echo "Looking for $TARBALL_FILENAME in $HERMES_TARBALL_ARTIFACTS_DIR" + echo "$TARBALL_PATH" + + if [ ! -f $TARBALL_PATH ]; then + echo "Hermes tarball not present ($TARBALL_PATH). Build Hermes from source." + exit 0 + fi + + echo "Found Hermes tarball at $TARBALL_PATH" + echo "HERMES_ENGINE_TARBALL_PATH=$TARBALL_PATH" >> $GITHUB_ENV + - name: Download ReactNativeDependencies + continue-on-error: true + uses: actions/download-artifact@v4 + with: + name: ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz + path: /tmp/third-party/ + - name: Extract ReactNativeDependencies + if: steps.restore-macos-slice.outputs.cache-hit != 'true' + shell: bash + run: | + # Check if ReactNativeDependencies tarball exists + if [ ! -f /tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz ]; then + echo "ReactNativeDependencies tarball not found, skipping extraction" + exit 0 + fi + + # Extract ReactNativeDependencies + tar -xzf /tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz -C /tmp/third-party/ + + # Create destination folder + mkdir -p packages/react-native/third-party/ + + # Move the XCFramework in the destination directory + mv /tmp/third-party/packages/react-native/third-party/ReactNativeDependencies.xcframework packages/react-native/third-party/ReactNativeDependencies.xcframework + + VERSION=$(jq -r '.version' package.json) + echo "$VERSION-${{matrix.flavor}}" > "packages/react-native/third-party/version.txt" + cat "packages/react-native/third-party/version.txt" + # Check destination directory + ls -lR packages/react-native/third-party/ + - name: Setup the workspace + if: steps.restore-macos-slice.outputs.cache-hit != 'true' + continue-on-error: true + shell: bash + run: | + cd packages/react-native + node scripts/ios-prebuild.js -s -f "${{ matrix.flavor }}" + - name: Build React Native + if: steps.restore-macos-slice.outputs.cache-hit != 'true' + shell: bash + run: | + # This is going to be replaced by a CLI script + cd packages/react-native + node scripts/ios-prebuild -b -f "${{ matrix.flavor }}" -p "${{ matrix.slice }}" + - name: Upload headers + uses: actions/upload-artifact@v4 + with: + name: prebuild-macos-core-headers-${{ matrix.flavor }}-${{ matrix.slice }} + path: + packages/react-native/.build/headers + - name: Upload artifacts + uses: actions/upload-artifact@v4.3.4 + with: + name: prebuild-macos-core-slice-${{ matrix.flavor }}-${{ matrix.slice }} + path: | + packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products + - name: Save Cache + uses: actions/cache/save@v4 + if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode + with: + key: v1-macos-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }} + path: | + packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products + packages/react-native/.build/headers + + compose-xcframework: + runs-on: macos-14 + timeout-minutes: 60 + needs: [build-rn-slice] + strategy: + fail-fast: false + matrix: + flavor: ['Debug', 'Release'] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Restore cache if present + id: restore-macos-xcframework + uses: actions/cache/restore@v4 + with: + path: packages/react-native/.build/output/xcframeworks + key: v1-macos-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }} + - name: Setup toolchain + if: steps.restore-macos-xcframework.outputs.cache-hit != 'true' + uses: ./.github/actions/microsoft-setup-toolchain + with: + platform: macos + node-version: '22' + xcode-developer-dir: '/Applications/Xcode_16.2.0.app' + - name: Yarn Install + if: steps.restore-macos-xcframework.outputs.cache-hit != 'true' + run: yarn install + shell: bash + - name: Download slice artifacts + if: steps.restore-macos-xcframework.outputs.cache-hit != 'true' + uses: actions/download-artifact@v4 + with: + pattern: prebuild-macos-core-slice-${{ matrix.flavor }}-* + path: packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products + merge-multiple: true + - name: Download headers + if: steps.restore-macos-xcframework.outputs.cache-hit != 'true' + uses: actions/download-artifact@v4 + with: + pattern: prebuild-macos-core-headers-${{ matrix.flavor }}-* + path: packages/react-native/.build/headers + merge-multiple: true + - name: Create XCFramework + if: steps.restore-macos-xcframework.outputs.cache-hit != 'true' + run: | + cd packages/react-native + node scripts/ios-prebuild -c -f "${{ matrix.flavor }}" + - name: Compress and Rename XCFramework + if: steps.restore-macos-xcframework.outputs.cache-hit != 'true' + run: | + cd packages/react-native/.build/output/xcframeworks/${{matrix.flavor}} + tar -cz -f ../ReactCoreMacOS${{matrix.flavor}}.xcframework.tar.gz React.xcframework + - name: Compress and Rename dSYM + if: steps.restore-macos-xcframework.outputs.cache-hit != 'true' + run: | + cd packages/react-native/.build/output/xcframeworks/${{matrix.flavor}}/Symbols + tar -cz -f ../../ReactCoreMacOS${{ matrix.flavor }}.framework.dSYM.tar.gz . + - name: Upload XCFramework Artifact + uses: actions/upload-artifact@v4 + with: + name: ReactCoreMacOS${{ matrix.flavor }}.xcframework.tar.gz + path: packages/react-native/.build/output/xcframeworks/ReactCoreMacOS${{matrix.flavor}}.xcframework.tar.gz + - name: Upload dSYM Artifact + uses: actions/upload-artifact@v4 + with: + name: ReactCoreMacOS${{ matrix.flavor }}.framework.dSYM.tar.gz + path: packages/react-native/.build/output/xcframeworks/ReactCoreMacOS${{matrix.flavor}}.framework.dSYM.tar.gz + - name: Save cache if present + if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode + uses: actions/cache/save@v4 + with: + path: | + packages/react-native/.build/output/xcframeworks/ReactCoreMacOS${{matrix.flavor}}.xcframework.tar.gz + packages/react-native/.build/output/xcframeworks/ReactCoreMacOS${{matrix.flavor}}.framework.dSYM.tar.gz + key: v1-macos-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }} diff --git a/packages/react-native/Package.swift b/packages/react-native/Package.swift index c387085ea2368f..b814bfc537e9e9 100644 --- a/packages/react-native/Package.swift +++ b/packages/react-native/Package.swift @@ -246,7 +246,7 @@ let reactJsErrorHandler = RNTarget( let reactGraphicsApple = RNTarget( name: .reactGraphicsApple, path: "ReactCommon/react/renderer/graphics/platform/ios", - linkedFrameworks: ["UIKit", "CoreGraphics"], + linkedFrameworks: ["CoreGraphics"], dependencies: [.reactDebug, .jsi, .reactUtils, .reactNativeDependencies] ) @@ -376,7 +376,6 @@ let reactFabric = RNTarget( "components/view/tests", "components/view/platform/android", "components/view/platform/windows", - "components/view/platform/macos", "components/scrollview/tests", "components/scrollview/platform/android", "mounting/tests", @@ -420,16 +419,13 @@ let reactFabricComponents = RNTarget( "components/modal/platform/cxx", "components/view/platform/android", "components/view/platform/windows", - "components/view/platform/macos", "components/textinput/platform/android", "components/text/platform/android", - "components/textinput/platform/macos", "components/text/tests", "textlayoutmanager/tests", "textlayoutmanager/platform/android", "textlayoutmanager/platform/cxx", "textlayoutmanager/platform/windows", - "textlayoutmanager/platform/macos", "conponents/rncore", // this was the old folder where RN Core Components were generated. If you ran codegen in the past, you might have some files in it that might make the build fail. ], dependencies: [.reactNativeDependencies, .reactCore, .reactJsiExecutor, .reactTurboModuleCore, .jsi, .logger, .reactDebug, .reactFeatureFlags, .reactUtils, .reactRuntimeScheduler, .reactCxxReact, .yoga, .reactRendererDebug, .reactGraphics, .reactFabric, .reactTurboModuleBridging], @@ -587,7 +583,7 @@ let targets = [ let package = Package( name: react, - platforms: [.iOS(.v15), .macCatalyst(SupportedPlatform.MacCatalystVersion.v13)], + platforms: [.iOS(.v15), .macOS(.v14), .macCatalyst(SupportedPlatform.MacCatalystVersion.v13)], products: [ .library( name: react, @@ -792,6 +788,13 @@ extension Target { .define("USE_HERMES", to: "1"), ] + defines + cxxCommonHeaderPaths + // Platform-specific framework linking + var conditionalLinkerSettings: [LinkerSetting] = linkerSettings + if name == "React-graphics-Apple" { + conditionalLinkerSettings.append(.linkedFramework("UIKit", .when(platforms: [.iOS, .visionOS]))) + conditionalLinkerSettings.append(.linkedFramework("AppKit", .when(platforms: [.macOS]))) + } + return .target( name: name, dependencies: dependencies, @@ -800,7 +803,7 @@ extension Target { sources: sources, publicHeadersPath: publicHeadersPath, cxxSettings: cxxSettings, - linkerSettings: linkerSettings + linkerSettings: conditionalLinkerSettings ) } } diff --git a/packages/react-native/scripts/ios-prebuild/cli.js b/packages/react-native/scripts/ios-prebuild/cli.js index 01301c800af717..ec3cf8d9f60a35 100644 --- a/packages/react-native/scripts/ios-prebuild/cli.js +++ b/packages/react-native/scripts/ios-prebuild/cli.js @@ -17,6 +17,7 @@ import type {BuildFlavor, Destination, Platform} from './types'; const platforms /*: $ReadOnlyArray */ = [ 'ios', 'ios-simulator', + 'macos', 'mac-catalyst', ]; @@ -25,6 +26,7 @@ const platforms /*: $ReadOnlyArray */ = [ const platformToDestination /*: $ReadOnly<{|[Platform]: Destination|}> */ = { ios: 'iOS', 'ios-simulator': 'iOS Simulator', + 'macos': 'macOS', 'mac-catalyst': 'macOS,variant=Mac Catalyst', };