Skip to content

Commit bfa7c9b

Browse files
Saadnajmiclaude
andcommitted
feat: include macOS slice in Hermes xcframework
- Make HERMES_PATH overridable via environment variable so CI can point to a separately cloned Hermes repo - Add CMAKE_OSX_DEPLOYMENT_TARGET to build_host_hermesc to fix -Werror=unguarded-availability-new failures in LLVM cmake checks - Add macOS deployment target support via get_mac_deployment_target Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 49cb7d9 commit bfa7c9b

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

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

Lines changed: 7 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,12 @@ 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+
# Set a deployment target to prevent -Werror=unguarded-availability-new
64+
# failures in LLVM's check_symbol_exists tests (macOS SDK headers contain
65+
# availability annotations that error without a deployment target).
66+
cmake -S . -B build_host_hermesc \
67+
-DJSI_DIR="$JSI_PATH" \
68+
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="${MAC_DEPLOYMENT_TARGET:-10.15}"
6469
cmake --build ./build_host_hermesc --target hermesc -j "${NUM_CORES}"
6570
popd > /dev/null || exit 1
6671
}

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)