Skip to content

Add debuginfo support for build_xcframework #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 38 additions & 7 deletions Scripts/build_xcframework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,33 @@ framework module OpenGraph {
}
EOF

PACKAGE_NAME=$1
# Parse arguments
DEBUG_INFO=false
PACKAGE_NAME=""

while [[ $# -gt 0 ]]; do
case $1 in
--debug-info)
DEBUG_INFO=true
shift
;;
*)
if [ -z "$PACKAGE_NAME" ]; then
PACKAGE_NAME="$1"
fi
shift
;;
esac
done

if [ -z "$PACKAGE_NAME" ]; then
echo "No package name provided. Using the first scheme found in the Package.swift."
PACKAGE_NAME=$(xcodebuild -list | awk 'schemes && NF>0 { print $1; exit } /Schemes:$/ { schemes = 1 }')
echo "Using: $PACKAGE_NAME"
fi

echo "Building xcframework for package: $PACKAGE_NAME contains debug info: $DEBUG_INFO"

build_framework() {
local sdk="$1"
local destination="$2"
Expand Down Expand Up @@ -97,10 +117,21 @@ echo "Builds completed successfully."
cd $PROJECT_BUILD_DIR

rm -rf "$PACKAGE_NAME.xcframework"
xcodebuild -create-xcframework \
-framework $PACKAGE_NAME-iphonesimulator.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
-framework $PACKAGE_NAME-iphoneos.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
-framework $PACKAGE_NAME-macosx.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
-output $PACKAGE_NAME.xcframework

cp -r $PACKAGE_NAME-iphonesimulator.xcarchive/dSYMs $PACKAGE_NAME.xcframework/ios-arm64_x86_64-simulator
if [ "$DEBUG_INFO" = true ]; then
echo "Creating xcframework with debug symbols..."
xcodebuild -create-xcframework \
-framework $PACKAGE_NAME-iphonesimulator.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
-debug-symbols "$(realpath $PACKAGE_NAME-iphonesimulator.xcarchive/dSYMs/$PACKAGE_NAME.framework.dSYM)" \
-framework $PACKAGE_NAME-iphoneos.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
-debug-symbols "$(realpath $PACKAGE_NAME-iphoneos.xcarchive/dSYMs/$PACKAGE_NAME.framework.dSYM)" \
-framework $PACKAGE_NAME-macosx.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
-debug-symbols "$(realpath $PACKAGE_NAME-macosx.xcarchive/dSYMs/$PACKAGE_NAME.framework.dSYM)" \
-output $PACKAGE_NAME.xcframework
else
xcodebuild -create-xcframework \
-framework $PACKAGE_NAME-iphonesimulator.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
-framework $PACKAGE_NAME-iphoneos.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
-framework $PACKAGE_NAME-macosx.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework \
-output $PACKAGE_NAME.xcframework
fi