Skip to content

Commit 9ec8692

Browse files
authored
Add debuginfo support for build_xcframework (#151)
1 parent 5df0e1b commit 9ec8692

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

Scripts/build_xcframework.sh

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,33 @@ framework module OpenGraph {
2121
}
2222
EOF
2323

24-
PACKAGE_NAME=$1
24+
# Parse arguments
25+
DEBUG_INFO=false
26+
PACKAGE_NAME=""
27+
28+
while [[ $# -gt 0 ]]; do
29+
case $1 in
30+
--debug-info)
31+
DEBUG_INFO=true
32+
shift
33+
;;
34+
*)
35+
if [ -z "$PACKAGE_NAME" ]; then
36+
PACKAGE_NAME="$1"
37+
fi
38+
shift
39+
;;
40+
esac
41+
done
42+
2543
if [ -z "$PACKAGE_NAME" ]; then
2644
echo "No package name provided. Using the first scheme found in the Package.swift."
2745
PACKAGE_NAME=$(xcodebuild -list | awk 'schemes && NF>0 { print $1; exit } /Schemes:$/ { schemes = 1 }')
2846
echo "Using: $PACKAGE_NAME"
2947
fi
3048

49+
echo "Building xcframework for package: $PACKAGE_NAME contains debug info: $DEBUG_INFO"
50+
3151
build_framework() {
3252
local sdk="$1"
3353
local destination="$2"
@@ -97,10 +117,21 @@ echo "Builds completed successfully."
97117
cd $PROJECT_BUILD_DIR
98118

99119
rm -rf "$PACKAGE_NAME.xcframework"
100-
xcodebuild -create-xcframework \
101-
-framework $PACKAGE_NAME-iphonesimulator.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
102-
-framework $PACKAGE_NAME-iphoneos.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
103-
-framework $PACKAGE_NAME-macosx.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
104-
-output $PACKAGE_NAME.xcframework
105120

106-
cp -r $PACKAGE_NAME-iphonesimulator.xcarchive/dSYMs $PACKAGE_NAME.xcframework/ios-arm64_x86_64-simulator
121+
if [ "$DEBUG_INFO" = true ]; then
122+
echo "Creating xcframework with debug symbols..."
123+
xcodebuild -create-xcframework \
124+
-framework $PACKAGE_NAME-iphonesimulator.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
125+
-debug-symbols "$(realpath $PACKAGE_NAME-iphonesimulator.xcarchive/dSYMs/$PACKAGE_NAME.framework.dSYM)" \
126+
-framework $PACKAGE_NAME-iphoneos.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
127+
-debug-symbols "$(realpath $PACKAGE_NAME-iphoneos.xcarchive/dSYMs/$PACKAGE_NAME.framework.dSYM)" \
128+
-framework $PACKAGE_NAME-macosx.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
129+
-debug-symbols "$(realpath $PACKAGE_NAME-macosx.xcarchive/dSYMs/$PACKAGE_NAME.framework.dSYM)" \
130+
-output $PACKAGE_NAME.xcframework
131+
else
132+
xcodebuild -create-xcframework \
133+
-framework $PACKAGE_NAME-iphonesimulator.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
134+
-framework $PACKAGE_NAME-iphoneos.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
135+
-framework $PACKAGE_NAME-macosx.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
136+
-output $PACKAGE_NAME.xcframework
137+
fi

0 commit comments

Comments
 (0)