Skip to content

Commit 87dcd49

Browse files
Saadnajmimeta-codesync[bot]
authored andcommitted
fix: include macOS slice in universal Hermes xcframework (#1970)
Summary: Mirror of #1958 (targeting `static_h`), adapted for the legacy `main` branch. Unlike the `static_h` PR which consolidates all Apple build scripts and removes `build-mac-framework.sh`, this PR takes a minimal approach: it adds macOS support to the existing `build-ios-framework.sh` functions (`get_architecture`, `get_deployment_target`, `create_framework`, `build_universal_framework`) so the macOS slice is included in the universal xcframework. `build-mac-framework.sh` is left in place for backward compatibility on this legacy branch. ### Motivation The context of this change is microsoft/react-native-macos#2815, where we are adding SPM / prebuild support to React Native macOS. Including the macOS slice in the universal xcframework allows [react-native-macos](https://github.com/microsoft/react-native-macos) to use the same prebuilt Hermes artifacts as react-native for iOS, visionOS, and tvOS — without platform-specific patching. Pull Request resolved: #1970 Test Plan: CI should pass. The `build_apple_framework "macosx"` call is already exercised by `build-mac-framework.sh` — this PR just routes it through the same path as every other platform. Reviewed By: cortinico Differential Revision: D104042922 Pulled By: cipolleschi fbshipit-source-id: 4dafaf4c21361919ec240ee2cf7e3237041fecdd
1 parent 62c4edd commit 87dcd49

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

utils/build-apple-framework.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,12 @@ function create_universal_framework {
232232
# shellcheck disable=SC2086
233233
if xcodebuild -create-xcframework $args -output "universal/hermesvm.xcframework"
234234
then
235-
# # Remove the thin iOS hermesvm.frameworks that are now part of the universal
236-
# XCFramework
235+
# Remove the thin hermesvm.frameworks that are now part of the universal
236+
# XCFramework, but keep macosx since it's expected as a standalone framework.
237237
for platform in "${platforms[@]}"; do
238-
rm -r "$platform"
238+
if [[ "$platform" != "macosx" ]]; then
239+
rm -r "$platform"
240+
fi
239241
done
240242
fi
241243

utils/build-ios-framework.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,9 @@ set -e
1212
# Given a specific target, retrieve the right architecture for it
1313
# $1 the target you want to build. Allowed values: iphoneos, iphonesimulator, catalyst, xros, xrsimulator
1414
function get_architecture {
15-
if [[ $1 == "iphoneos" || $1 == "xros" ]]; then
15+
if [[ $1 == "iphoneos" || $1 == "appletvos" || $1 == "xros" ]]; then
1616
echo "arm64"
17-
elif [[ $1 == "iphonesimulator" || $1 == "xrsimulator" ]]; then
18-
echo "x86_64;arm64"
19-
elif [[ $1 == "appletvos" ]]; then
20-
echo "arm64"
21-
elif [[ $1 == "appletvsimulator" ]]; then
22-
echo "x86_64;arm64"
23-
elif [[ $1 == "catalyst" ]]; then
17+
elif [[ $1 == "iphonesimulator" || $1 == "appletvsimulator" || $1 == "catalyst" || $1 == "macosx" || $1 == "xrsimulator" ]]; then
2418
echo "x86_64;arm64"
2519
else
2620
echo "Error: unknown architecture passed $1"
@@ -29,7 +23,9 @@ function get_architecture {
2923
}
3024

3125
function get_deployment_target {
32-
if [[ $1 == "xros" || $1 == "xrsimulator" ]]; then
26+
if [[ $1 == "macosx" ]]; then
27+
echo "$(get_mac_deployment_target)"
28+
elif [[ $1 == "xros" || $1 == "xrsimulator" ]]; then
3329
echo "$(get_visionos_deployment_target)"
3430
else # tvOS and iOS use the same deployment target
3531
echo "$(get_ios_deployment_target)"
@@ -51,7 +47,7 @@ function build_framework {
5147
# group the frameworks together to create a universal framework
5248
function build_universal_framework {
5349
if [ ! -d destroot/Library/Frameworks/universal/hermesvm.xcframework ]; then
54-
create_universal_framework "iphoneos" "iphonesimulator" "catalyst" "xros" "xrsimulator" "appletvos" "appletvsimulator"
50+
create_universal_framework "macosx" "iphoneos" "iphonesimulator" "catalyst" "xros" "xrsimulator" "appletvos" "appletvsimulator"
5551
else
5652
echo "Skipping; Clean \"destroot\" to rebuild".
5753
fi
@@ -61,6 +57,7 @@ function build_universal_framework {
6157
# this is used to preserve backward compatibility
6258
function create_framework {
6359
if [ ! -d destroot/Library/Frameworks/universal/hermesvm.xcframework ]; then
60+
build_framework "macosx"
6461
build_framework "iphoneos"
6562
build_framework "iphonesimulator"
6663
build_framework "appletvos"

0 commit comments

Comments
 (0)