Skip to content

feat(0.81): build React Native macOS with Swift Package Manager#2916

Draft
Saadnajmi wants to merge 4 commits intomicrosoft:0.81-stablefrom
Saadnajmi:feature/spm-macos-support-0.81
Draft

feat(0.81): build React Native macOS with Swift Package Manager#2916
Saadnajmi wants to merge 4 commits intomicrosoft:0.81-stablefrom
Saadnajmi:feature/spm-macos-support-0.81

Conversation

@Saadnajmi
Copy link
Copy Markdown
Collaborator

Summary

  • Backports SPM macOS support from feat: build React Native macOS with Swift Package Manager #2815 (main branch) to 0.81-stable
  • Key adaptation: RCTUIKit is part of React-Core on 0.81 (not a separate module), so platformLinkerSettings for UIKit/AppKit go directly on the reactCore target
  • Adds macOS/visionOS platform support, Hermes CI pipeline, and macOS view platform conditionals

Changes from main branch PR

  • No separate reactRCTUIKit target — UIKit/AppKit compat is inside React-Core
  • platformLinkerSettings on reactCore instead of reactRCTUIKit
  • No RCTUIKit header link in setup.js (not needed since it's part of React-Core)
  • ENTERPRISE_REPOSITORY env var preserved in getTarballUrl (0.81-specific)

Test plan

  • CI: resolve-hermes job passes
  • CI: build-hermesc job passes
  • CI: all hermes slice builds pass (iphoneos, iphonesimulator, catalyst, macosx, xros)
  • CI: assemble-hermes produces xcframework
  • CI: SPM ios build passes
  • CI: SPM macos build passes
  • CI: SPM visionos build passes
  • Local: node scripts/prebuild-ios -s -f Debug completes setup
  • Local: node scripts/prebuild-ios -b -f Debug -p macos builds for macOS

🤖 Generated with Claude Code

Adapts the SPM macOS support from the main branch for the 0.81-stable
branch. Key difference from main: RCTUIKit is part of React-Core on 0.81
(not a separate module), so platformLinkerSettings for UIKit/AppKit go
directly on the reactCore target.

Changes:
- Add macOS/visionOS platform support to ios-prebuild CLI and types
- Add macOS version resolution via macosVersionResolver.js (fork-only)
- Add Hermes build-from-source fallback for main branch builds
- Add macOS platform to Package.swift with platform-conditional linking
- Add macOS view platform sources/excludes to reactFabric
- Add macOS view platform header links in setup.js
- Add Hermes CI workflow for building macOS slices
- Make HERMES_PATH overridable in build-apple-framework.sh
- Add macOS slice to build-ios-framework.sh

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Saadnajmi Saadnajmi changed the title Backport SPM macOS support to 0.81-stable feat(0.81): build React Native macOS with Swift Package Manager Apr 11, 2026
Saadnajmi and others added 3 commits April 10, 2026 19:44
The SPM workflow is triggered via workflow_call from microsoft-pr.yml,
which was missing on 0.81-stable. Add the build-spm job so CI runs the
SPM pipeline on PRs targeting this branch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
IOSSwitchShadowNode.mm imports UIKit which doesn't exist on macOS.
Use #if os(macOS) to exclude the iOS variant and include the macOS
variant (and vice versa on iOS), matching the existing pattern for
view platform sources.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Package.swift's #if os(macOS) runs on the host (always macOS), not
the target platform. This meant iOS builds got macOS switch excludes,
causing AppKit import errors.

Instead of conditionally excluding files in Package.swift, add
#if TARGET_OS_OSX guards directly in the .mm files. Both files are
now included in all builds but compile to empty on the wrong platform.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant