Skip to content
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

chore: introduce script to make a single XCFramework #881

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Sources/Configuration/Sentry.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SDKROOT__CARTHAGE_ = iphoneos
// ⋯ quite early in the process, queried values not compiled into Carthage will cause hard errors.
SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator watchos watchsimulator appletvos appletvsimulator
TARGETED_DEVICE_FAMILY = 1,2,3,4
SKIP_INSTALL = YES
SKIP_INSTALL = NO

DEFINES_MODULE = YES
DYLIB_COMPATIBILITY_VERSION = 1
Expand Down
33 changes: 33 additions & 0 deletions scripts/build-xcf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
# Builds XCFramework of all the possible destinations

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR/.." || exit 1
ARCHIVES_DIR="./Archives"
XCF_OUTPUT="./Sentry.xcframework"

mkdir -p "$ARCHIVES_DIR"
rm -rf "$XCF_OUTPUT"

archive() {
xcodebuild archive -workspace Sentry.xcworkspace -scheme Sentry -destination "$1" -archivePath "$ARCHIVES_DIR/$2"
}

archive "generic/platform=iOS" "Sentry-ios"
archive "generic/platform=iOS Simulator" "Sentry-iossimulator"
archive "generic/platform=watchOS" "Sentry-watchos"
# This gets a warning due to matching both mac & mac-catalyst variants, but unclear how to be specific
archive "generic/platform=macOS" "Sentry-mac"
archive "generic/platform=macOS,variant=Mac Catalyst" "Sentry-maccatalyst"

# Combine them all into an XCFramework
XCARGS=()

# Thanks to shellcheck this got a little weirder, likely simpler if switched to zsh due to macOS bash's age
while IFS= read -r -d '' file
do
XCARGS+=("-framework")
XCARGS+=("$file")
done < <(find "$ARCHIVES_DIR" -name 'Sentry.framework' -print0)

xcodebuild -create-xcframework "${XCARGS[@]}" -output "$XCF_OUTPUT"