Skip to content

Commit b5bb227

Browse files
hramosfacebook-github-bot
authored andcommitted
Hermes: Include iOS debug symbols in Hermes XCFramework
Summary: Include dSYMs when building the universal XCFramework for Hermes iOS. CocoaPods should pick up dSYMs automatically when using `vendored_framework` if: - `hermes.framework` has a `hermes.framework.dSYM` in the same base directory - `hermes.xcframework` has a `dSYMs` folder with a `hermes.framework.dSYM` in it, for each slice The dSYMs for the macOS hermes.framework are already being created. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D40790250 fbshipit-source-id: 50fcb3492434637b00458c1aa443ac6ec5472fac
1 parent 7964d48 commit b5bb227

File tree

1 file changed

+57
-34
lines changed

1 file changed

+57
-34
lines changed

sdks/hermes-engine/utils/build-apple-framework.sh

Lines changed: 57 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,19 @@
44
# This source code is licensed under the MIT license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
NUM_CORES=$(sysctl -n hw.ncpu)
7+
# Defines functions for building various Hermes frameworks.
8+
# See build-ios-framework.sh and build-mac-framework.sh for usage examples.
9+
10+
CURR_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
11+
812
IMPORT_HERMESC_PATH=${HERMES_OVERRIDE_HERMESC_PATH:-$PWD/build_host_hermesc/ImportHermesc.cmake}
9-
REACT_NATIVE_PATH=${REACT_NATIVE_PATH:-$PWD/../..}
13+
BUILD_TYPE=${BUILD_TYPE:-Debug}
14+
15+
HERMES_PATH="$CURR_SCRIPT_DIR/.."
16+
REACT_NATIVE_PATH=${REACT_NATIVE_PATH:-$CURR_SCRIPT_DIR/../../..}
17+
18+
NUM_CORES=$(sysctl -n hw.ncpu)
19+
1020
if [[ -z "$JSI_PATH" ]]; then
1121
JSI_PATH="$REACT_NATIVE_PATH/ReactCommon/jsi"
1222
fi
@@ -34,8 +44,10 @@ function get_mac_deployment_target {
3444
# Build host hermes compiler for internal bytecode
3545
function build_host_hermesc {
3646
echo "Building hermesc"
37-
cmake -S . -B build_host_hermesc
38-
cmake --build ./build_host_hermesc --target hermesc -j ${NUM_CORES}
47+
pushd "$HERMES_PATH" > /dev/null || exit 1
48+
cmake -S . -B build_host_hermesc -DJSI_DIR="$JSI_PATH"
49+
cmake --build ./build_host_hermesc --target hermesc -j "${NUM_CORES}"
50+
popd > /dev/null || exit 1
3951
}
4052

4153
# Utility function to configure an Apple framework
@@ -58,30 +70,30 @@ function configure_apple_framework {
5870
enable_debugger="false"
5971
fi
6072

61-
cmake -S . -B "build_$1" \
62-
-DHERMES_APPLE_TARGET_PLATFORM:STRING="$1" \
63-
-DCMAKE_OSX_ARCHITECTURES:STRING="$2" \
64-
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="$3" \
65-
-DHERMES_ENABLE_DEBUGGER:BOOLEAN="$enable_debugger" \
66-
-DHERMES_ENABLE_INTL:BOOLEAN=true \
67-
-DHERMES_ENABLE_LIBFUZZER:BOOLEAN=false \
68-
-DHERMES_ENABLE_FUZZILLI:BOOLEAN=false \
69-
-DHERMES_ENABLE_TEST_SUITE:BOOLEAN=false \
70-
-DHERMES_ENABLE_BITCODE:BOOLEAN="$enable_bitcode" \
71-
-DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=true \
72-
-DHERMES_BUILD_APPLE_DSYM:BOOLEAN=true \
73-
-DHERMES_ENABLE_TOOLS:BOOLEAN="$build_cli_tools" \
74-
-DIMPORT_HERMESC:PATH="$IMPORT_HERMESC_PATH" \
75-
-DJSI_DIR="$JSI_PATH" \
76-
-DHERMES_RELEASE_VERSION="for RN $(get_release_version)" \
77-
-DCMAKE_INSTALL_PREFIX:PATH=../destroot \
78-
-DCMAKE_BUILD_TYPE="$BUILD_TYPE"
73+
pushd "$HERMES_PATH" > /dev/null || exit 1
74+
cmake -S . -B "build_$1" \
75+
-DHERMES_APPLE_TARGET_PLATFORM:STRING="$1" \
76+
-DCMAKE_OSX_ARCHITECTURES:STRING="$2" \
77+
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="$3" \
78+
-DHERMES_ENABLE_DEBUGGER:BOOLEAN="$enable_debugger" \
79+
-DHERMES_ENABLE_INTL:BOOLEAN=true \
80+
-DHERMES_ENABLE_LIBFUZZER:BOOLEAN=false \
81+
-DHERMES_ENABLE_FUZZILLI:BOOLEAN=false \
82+
-DHERMES_ENABLE_TEST_SUITE:BOOLEAN=false \
83+
-DHERMES_ENABLE_BITCODE:BOOLEAN="$enable_bitcode" \
84+
-DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=true \
85+
-DHERMES_BUILD_APPLE_DSYM:BOOLEAN=true \
86+
-DHERMES_ENABLE_TOOLS:BOOLEAN="$build_cli_tools" \
87+
-DIMPORT_HERMESC:PATH="$IMPORT_HERMESC_PATH" \
88+
-DJSI_DIR="$JSI_PATH" \
89+
-DHERMES_RELEASE_VERSION="for RN $(get_release_version)" \
90+
-DCMAKE_INSTALL_PREFIX:PATH=../destroot \
91+
-DCMAKE_BUILD_TYPE="$BUILD_TYPE"
92+
popd > /dev/null || exit 1
7993
}
8094

8195
# Utility function to build an Apple framework
8296
function build_apple_framework {
83-
echo "Building $BUILD_TYPE framework for $1 with architectures: $2"
84-
8597
# Only build host HermesC if no file found at $IMPORT_HERMESC_PATH
8698
[ ! -f "$IMPORT_HERMESC_PATH" ] &&
8799
build_host_hermesc
@@ -90,32 +102,43 @@ function build_apple_framework {
90102
[ ! -f "$IMPORT_HERMESC_PATH" ] &&
91103
echo "Host hermesc is required to build apple frameworks!"
92104

105+
echo "Building $BUILD_TYPE framework for $1 with architectures: $2"
93106
configure_apple_framework "$1" "$2" "$3"
94-
cmake --build "./build_$1" --target install/strip -j ${NUM_CORES}
107+
108+
pushd "$HERMES_PATH" > /dev/null || exit 1
109+
cmake --build "./build_$1" --target install/strip -j "${NUM_CORES}"
110+
popd > /dev/null || exit 1
95111
}
96112

97113
# Accepts an array of frameworks and will place all of
98114
# the architectures into an universal folder and then remove
99115
# the merged frameworks from destroot
100116
function create_universal_framework {
101-
cd ./destroot/Library/Frameworks || exit 1
117+
pushd "$HERMES_PATH/destroot/Library/Frameworks" > /dev/null || exit 1
102118

103119
local platforms=("$@")
104120
local args=""
105121

106122
echo "Creating universal framework for platforms: ${platforms[*]}"
107123

108124
for i in "${!platforms[@]}"; do
109-
args+="-framework ${platforms[$i]}/hermes.framework "
125+
local hermes_framework_path="${platforms[$i]}/hermes.framework"
126+
args+="-framework $hermes_framework_path "
127+
128+
# Path to dSYM must be absolute
129+
args+="-debug-symbols $HERMES_PATH/destroot/Library/Frameworks/$hermes_framework_path.dSYM "
110130
done
111131

112-
mkdir universal
132+
mkdir -p universal
113133
# shellcheck disable=SC2086
114-
xcodebuild -create-xcframework $args -output "universal/hermes.xcframework"
115-
116-
for platform in "$@"; do
117-
rm -r "$platform"
118-
done
134+
if xcodebuild -create-xcframework $args -output "universal/hermes.xcframework"
135+
then
136+
# # Remove the thin iOS hermes.frameworks that are now part of the universal
137+
# XCFramework
138+
for platform in "${platforms[@]}"; do
139+
rm -r "$platform"
140+
done
141+
fi
119142

120-
cd - || exit 1
143+
popd > /dev/null || exit 1
121144
}

0 commit comments

Comments
 (0)