Skip to content

Commit a87f33f

Browse files
committed
feat: include macOS slice in Hermes xcframework
Add macOS ("macosx") as a platform in build-ios-framework.sh so the universal Hermes xcframework includes a native macOS slice. Previously, macOS was built separately by build-mac-framework.sh but not included in the xcframework. Changes: - Add "macosx" to create_universal_framework and create_framework - Add macosx to get_architecture (x86_64;arm64) and get_deployment_target - Make HERMES_PATH overridable via env var in build-apple-framework.sh - Fix host hermesc build by setting CMAKE_OSX_SYSROOT via HERMES_APPLE_TARGET_PLATFORM
1 parent f02d4e7 commit a87f33f

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ CURR_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
1212
IMPORT_HERMESC_PATH=${HERMES_OVERRIDE_HERMESC_PATH:-$PWD/build_host_hermesc/ImportHermesc.cmake}
1313
BUILD_TYPE=${BUILD_TYPE:-Debug}
1414

15-
HERMES_PATH="$CURR_SCRIPT_DIR/.."
15+
HERMES_PATH=${HERMES_PATH:-"$CURR_SCRIPT_DIR/.."}
1616
REACT_NATIVE_PATH=${REACT_NATIVE_PATH:-$CURR_SCRIPT_DIR/../../..}
1717

1818
NUM_CORES=$(sysctl -n hw.ncpu)
@@ -60,7 +60,7 @@ function get_mac_deployment_target {
6060
function build_host_hermesc {
6161
echo "Building hermesc"
6262
pushd "$HERMES_PATH" > /dev/null || exit 1
63-
cmake -S . -B build_host_hermesc -DJSI_DIR="$JSI_PATH"
63+
cmake -S . -B build_host_hermesc -DJSI_DIR="$JSI_PATH" -DHERMES_APPLE_TARGET_PLATFORM="$(xcrun --sdk macosx --show-sdk-path)"
6464
cmake --build ./build_host_hermesc --target hermesc -j "${NUM_CORES}"
6565
popd > /dev/null || exit 1
6666
}

packages/react-native/sdks/hermes-engine/utils/build-ios-framework.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fi
1010
set -e
1111

1212
# Given a specific target, retrieve the right architecture for it
13-
# $1 the target you want to build. Allowed values: iphoneos, iphonesimulator, catalyst, xros, xrsimulator
13+
# $1 the target you want to build. Allowed values: iphoneos, iphonesimulator, catalyst, macosx, xros, xrsimulator
1414
function get_architecture {
1515
if [[ $1 == "iphoneos" || $1 == "xros" ]]; then
1616
echo "arm64"
@@ -20,7 +20,7 @@ function get_architecture {
2020
echo "arm64"
2121
elif [[ $1 == "appletvsimulator" ]]; then
2222
echo "x86_64;arm64"
23-
elif [[ $1 == "catalyst" ]]; then
23+
elif [[ $1 == "catalyst" || $1 == "macosx" ]]; then
2424
echo "x86_64;arm64"
2525
else
2626
echo "Error: unknown architecture passed $1"
@@ -29,7 +29,9 @@ function get_architecture {
2929
}
3030

3131
function get_deployment_target {
32-
if [[ $1 == "xros" || $1 == "xrsimulator" ]]; then
32+
if [[ $1 == "macosx" ]]; then
33+
echo "$(get_mac_deployment_target)"
34+
elif [[ $1 == "xros" || $1 == "xrsimulator" ]]; then
3335
echo "$(get_visionos_deployment_target)"
3436
else # tvOS and iOS use the same deployment target
3537
echo "$(get_ios_deployment_target)"
@@ -53,7 +55,7 @@ function build_framework {
5355
# group the frameworks together to create a universal framework
5456
function build_universal_framework {
5557
if [ ! -d destroot/Library/Frameworks/universal/hermes.xcframework ]; then
56-
create_universal_framework "iphoneos" "iphonesimulator" "catalyst" "xros" "xrsimulator" "appletvos" "appletvsimulator"
58+
create_universal_framework "macosx" "iphoneos" "iphonesimulator" "catalyst" "xros" "xrsimulator" "appletvos" "appletvsimulator"
5759
else
5860
echo "Skipping; Clean \"destroot\" to rebuild".
5961
fi
@@ -63,6 +65,7 @@ function build_universal_framework {
6365
# this is used to preserve backward compatibility
6466
function create_framework {
6567
if [ ! -d destroot/Library/Frameworks/universal/hermes.xcframework ]; then
68+
build_framework "macosx"
6669
build_framework "iphoneos"
6770
build_framework "iphonesimulator"
6871
build_framework "appletvos"

0 commit comments

Comments
 (0)