Skip to content

fix: include macOS slice in universal hermes xcframework#1958

Open
Saadnajmi wants to merge 3 commits intofacebook:static_hfrom
Saadnajmi:hermes-macos-xcframework
Open

fix: include macOS slice in universal hermes xcframework#1958
Saadnajmi wants to merge 3 commits intofacebook:static_hfrom
Saadnajmi:hermes-macos-xcframework

Conversation

@Saadnajmi
Copy link
Copy Markdown

@Saadnajmi Saadnajmi commented Mar 26, 2026

Summary

Mirror of facebook/react-native#56235

The context of this change is microsoft/react-native-macos#2815, where we are adding SPM / prebuild support to React Native macOS.

Currently, Hermes is compiled into 2 xcframeworks: a "macosx" one with just the macOS slice, and a "universal" one for the rest of the Apple platforms (iOS, visionOS, Mac Catalyst, tvOS, etc). This means React Native macOS needs extra diffs and patches to use the right Hermes framework. However, xcframeworks are multiplatform — there's no reason we can't just add the macOS slice to the "universal" one, making it truly universal.

Including the macOS slice in the universal xcframework allows react-native-macos to use the same prebuilt Hermes artifacts as react-native for iOS, visionOS, and tvOS — without platform-specific patching.

Changes

  • Consolidate the three separate Hermes Apple build scripts (build-apple-framework.sh, build-ios-framework.sh, build-mac-framework.sh) into a single build-apple-framework.sh that builds all platforms — including macOS — into one universal hermesvm.xcframework
  • Update the hermes-engine podspec so the Pre-built subspec uses the universal xcframework for macOS (matching iOS, tvOS, and visionOS)
  • Update CI workflows to use build-apple-framework.sh uniformly for all slices (no more macOS special-casing)
  • Remove standalone macOS framework validation from hermes-utils.js

Simpler variants of this change targeting main and 250829098.0.0-stable just add "macosx" to the existing build scripts without the full consolidation, since those are legacy/release branches.

Test plan

CI should pass. The build_apple_framework "macosx" codepath is already exercised by the existing build-mac-framework.sh — this PR just routes it through the same path as every other platform.

Consolidates the three separate Hermes Apple build scripts into a single
`build-apple-framework.sh` that builds all platforms — including macOS —
into one universal `hermesvm.xcframework`.

Previously macOS was built as a standalone `.framework` by a separate script
and excluded from the universal xcframework. This meant macOS had a different
distribution path from every other Apple platform.

- Merge `build-ios-framework.sh` and `build-mac-framework.sh` into
  `build-apple-framework.sh` using the `PLATFORMS` array as single source
  of truth
- Update podspec to point macOS at the universal xcframework
- Update CI workflows to use `build-apple-framework.sh` uniformly for
  all slices (no more macOS special-casing)
- Remove standalone macOS framework validation from hermes-utils.js

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the cleanup!

Comment thread utils/build-apple-framework.sh Outdated
@cipolleschi
Copy link
Copy Markdown
Contributor

CI is failing to build hermesc:

  clang: error: no such file or directory: 'Missing'
  clang: error: no such file or directory: 'MAC_DEPLOYMENT_TARGET'
  clang: error: no such file or directory: 'environment'
  clang: error: no such file or directory: 'variable'
  clang: error: invalid version number in '-mmacosx-version-min=error:'
  clang: error: invalid version number in '-mmacosx-version-min=error:'

we might have broken some file refs...

Copy link
Copy Markdown
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI needs to be fixed.

Saadnajmi added a commit to microsoft/react-native-macos that referenced this pull request Apr 15, 2026
## Summary

Extends the Hermes build scripts to include macOS slices in the
universal xcframework, and adds macOS support to the Swift Package
Manager build system.

Currently, Hermes builds a standalone macOS `.framework` via
`build-mac-framework.sh` but does **not** include it in the universal
`.xcframework` used by SPM. This means SPM consumers cannot target
macOS. This PR fixes that by adding `macosx` as a platform in
`build-ios-framework.sh`, so the macOS slice is built alongside iOS,
visionOS, tvOS, and catalyst — and included in the universal
xcframework.

This mirrors the upstream Hermes changes:
- facebook/hermes#1958 (`static_h` — full
consolidation)

### Commit 1: SPM macOS support
- Add `.macOS(.v14)` platform to `Package.swift`
- Create `React-RCTUIKit` as its own SPM module with conditional
UIKit/AppKit linking
- Port `findMatchingHermesVersion` and `hermesCommitAtMergeBase` from
Ruby to JS for Hermes version resolution
- Add macOS platform and destination to prebuild CLI
- Link RCTUIKit and macOS view platform headers in setup

### Commit 2: Include macOS slice in Hermes xcframework
- Add `"macosx"` to `create_universal_framework` and `create_framework`
in `build-ios-framework.sh`
- Add `macosx` cases to `get_architecture` (x86_64;arm64) and
`get_deployment_target`
- Make `HERMES_PATH` overridable via env var in
`build-apple-framework.sh`

### Commit 3: CI jobs
- Add `microsoft-build-spm.yml` reusable workflow with two stages:
- **Build Hermes**: Builds Hermes from source on `macos-15` (includes
the macOS slice)
- **Build SPM**: Uses the Hermes artifact to build SPM for ios, macos,
and visionos on `macos-26`
- Wire into PR gate in `microsoft-pr.yml`
- Add `cmake-version` input to `microsoft-setup-toolchain` to allow
skipping CMake installation
- Add visionos/visionos-simulator as supported platforms in the
ios-prebuild CLI

## Test plan
- [ ] CI: Build Hermes from source with macOS slice
- [ ] CI: SPM builds pass for iOS, macOS, visionOS
- [ ] CocoaPods builds verified locally for iOS, macOS, visionOS

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Consolidates the three separate Hermes Apple build scripts into a single
`build-apple-framework.sh` that builds all platforms — including macOS —
into one universal `hermesvm.xcframework`.

Previously macOS was built as a standalone `.framework` by a separate script
and excluded from the universal xcframework. This meant macOS had a different
distribution path from every other Apple platform.

- Merge `build-ios-framework.sh` and `build-mac-framework.sh` into
  `build-apple-framework.sh` using the `PLATFORMS` array as single source
  of truth
- Update podspec to point macOS at the universal xcframework
- Update CI workflows to use `build-apple-framework.sh` uniformly for
  all slices (no more macOS special-casing)
- Remove standalone macOS framework validation from hermes-utils.js

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Saadnajmi Saadnajmi force-pushed the hermes-macos-xcframework branch from 3b4b91a to 3f54159 Compare April 15, 2026 20:38
Address review feedback:
- Add build_hermesc and prepare_dest_root CLI subcommands so CI
  can execute the script directly instead of sourcing it
- Simplify get_architecture from 5 branches to 2
- Update usage comment to document new subcommands
- Remove redundant chmod +x calls (script is already 755 in git)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Saadnajmi Saadnajmi force-pushed the hermes-macos-xcframework branch from 3f54159 to 7eacac7 Compare April 15, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants