-
Notifications
You must be signed in to change notification settings - Fork 162
Harden SPM integration test to guard visionOS slices #3073
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| BRANCH_NAME="$1" | ||
| INCLUDE_VISIONOS=false | ||
| # visionOS device + simulator slices are included by default so the published | ||
| # xcframework never ships out of sync with Package.swift's .visionOS() platform. | ||
| # Use --skip-visionos on fast paths (e.g. regular PR validation) that do not have | ||
| # the visionOS SDK installed. --include-visionos is kept as a no-op alias for | ||
| # backward compatibility with existing callers. | ||
| INCLUDE_VISIONOS=true | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious about flipping the default here. Both callers in the repo already pass a flag explicitly - |
||
| SKIP_SAMPLE_APP=false | ||
|
|
||
| # Parse optional flags | ||
|
|
@@ -8,6 +13,9 @@ for arg in "$@"; do | |
| --include-visionos) | ||
| INCLUDE_VISIONOS=true | ||
| ;; | ||
| --skip-visionos) | ||
| INCLUDE_VISIONOS=false | ||
| ;; | ||
| --skip-sample-app) | ||
| SKIP_SAMPLE_APP=true | ||
| ;; | ||
|
|
@@ -19,6 +27,21 @@ current_date=$(date +"%Y-%m-%d %H:%M:%S") | |
|
|
||
| set -e | ||
|
|
||
| # xcodebuild steps below run with -quiet and redirect output to build.log, so a | ||
| # failure would otherwise exit with no actionable context in the CI log. On a | ||
| # non-zero exit, dump build.log so the underlying xcodebuild error is visible. | ||
| # This script is invoked via `sh`, so use a POSIX-compatible EXIT trap that | ||
| # checks the status rather than a bash-only ERR trap. | ||
| on_exit() | ||
| { | ||
| status=$? | ||
| if [ "$status" -ne 0 ]; then | ||
| echo "** Build step failed (exit $status). Contents of build.log: **" | ||
| cat build.log 2>/dev/null || echo "(build.log not found)" | ||
| fi | ||
| } | ||
| trap on_exit EXIT | ||
|
|
||
| # Build framework | ||
|
|
||
| echo "Building framework" | ||
|
|
@@ -35,11 +58,47 @@ if [ "$INCLUDE_VISIONOS" = true ]; then | |
| xcodebuild -sdk xros -configuration Release -workspace MSAL.xcworkspace -scheme "MSAL (iOS Framework)" archive SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -archivePath archive/visionOS CODE_SIGNING_ALLOWED=NO -quiet > build.log 2>&1 | ||
| XCFRAMEWORK_ARGS="$XCFRAMEWORK_ARGS -framework archive/visionOSSimulator.xcarchive/Products/Library/Frameworks/MSAL.framework -framework archive/visionOS.xcarchive/Products/Library/Frameworks/MSAL.framework" | ||
| else | ||
| echo "Skipping visionOS (use --include-visionos to include)" | ||
| echo "Skipping visionOS (use default, or pass --include-visionos, to include; --skip-visionos to opt out)" | ||
| fi | ||
|
|
||
| xcodebuild -create-xcframework $XCFRAMEWORK_ARGS -output framework/MSAL.xcframework > build.log 2>&1 | ||
|
|
||
| if [ "$INCLUDE_VISIONOS" = true ]; then | ||
| echo "Verifying visionOS slices are present in MSAL.xcframework" | ||
| if [ ! -f framework/MSAL.xcframework/Info.plist ]; then | ||
| echo "** ERROR: framework/MSAL.xcframework/Info.plist not found; xcframework creation likely failed. See build.log above. **" | ||
| exit 1 | ||
| fi | ||
| python3 - <<'PY' | ||
| import plistlib, sys | ||
|
|
||
| plist_path = "framework/MSAL.xcframework/Info.plist" | ||
| with open(plist_path, "rb") as f: | ||
| info = plistlib.load(f) | ||
|
|
||
| libraries = info.get("AvailableLibraries", []) | ||
|
mipetriu marked this conversation as resolved.
|
||
|
|
||
| def has_slice(platform, simulator): | ||
| for lib in libraries: | ||
| is_sim = lib.get("SupportedPlatformVariant") == "simulator" | ||
| if lib.get("SupportedPlatform") == platform and is_sim == simulator: | ||
| return True | ||
| return False | ||
|
|
||
| missing = [] | ||
| if not has_slice("xros", False): | ||
| missing.append("visionOS device (xros)") | ||
| if not has_slice("xros", True): | ||
| missing.append("visionOS simulator (xros-simulator)") | ||
|
|
||
| if missing: | ||
| sys.stderr.write("** ERROR: MSAL.xcframework is missing required slices: " + ", ".join(missing) + " **\n") | ||
| sys.exit(1) | ||
|
|
||
| print("Verified visionOS device + simulator slices are present in MSAL.xcframework") | ||
| PY | ||
| fi | ||
|
|
||
| echo "Creating MSAL.zip" | ||
| zip -r MSAL.zip framework/MSAL.xcframework -y -v | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.