build: Add XCFramework binary distribution support#266
Open
cameroncooke wants to merge 1 commit into
Open
Conversation
Generate the vendored SnapshotPreviews frameworks with a Bash-based Xcode archive flow and a build-only package manifest that forces dynamic products for packaging. Add a binary-framework DemoApp example, document the manual integration requirements, and update release packaging to publish the generated XCFramework artifacts from the XCFrameworks directory. Co-Authored-By: Codex <noreply@openai.com>
NicoHinderling
approved these changes
Jun 5, 2026
Contributor
NicoHinderling
left a comment
There was a problem hiding this comment.
hopefully @noahsmartin can take a look as well
| run: bash build.sh | ||
| - name: Zip xcframeworks | ||
| run: | | ||
| rm -f *.xcframework.zip |
Contributor
Author
There was a problem hiding this comment.
I'll fix that. Bit pointless as the runner will be torn down.
jamieQ
reviewed
Jun 5, 2026
| "iphonesimulator|generic/platform=iOS Simulator" | ||
| "macosx|generic/platform=macOS" | ||
| "watchos|generic/platform=watchOS" | ||
| "watchsimulator|generic/platform=watchOS Simulator" |
Member
There was a problem hiding this comment.
How did we come up with this set of platforms? Should "visionos", "tvos", etc be in there?
| sanitize_swift_interfaces "$modules_path" "$framework" | ||
| } | ||
|
|
||
| sanitize_swift_interfaces() { |
Member
There was a problem hiding this comment.
What's the motiviation for this logic? Seems it's not new, but just curious
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds XCFramework binary distribution support for SnapshotPreviews while keeping the standard Swift Package integration source-first.
The release build now produces the full manually consumable framework set under
XCFrameworks/, packages those artifacts for GitHub releases, and includes a separate example project that integrates the generated frameworks without Swift Package Manager.Swift Package vs binary distribution
Package.swiftremains the public source-package manifest. SwiftPM is allowed to choose linkage for regular products, whileSnapshottingstays explicitly dynamic because it is the inserted/runtime dylib product.XCFrameworkPackage.swiftis a build-only manifest used bybuild.sh. It forces the currently built product to dynamic for binary packaging and wires already-built SnapshotPreviews dependencies back in as binary targets, so shared support modules are dynamically linked instead of being repeatedly embedded into parent frameworks.Vended artifact layout
Generated binary artifacts are written to
XCFrameworks/:SnapshotSharedModels.xcframeworkSnapshotPreviewsCore.xcframeworkSnapshotPreferences.xcframeworkPreviewGallery.xcframeworkSnapshottingTests.xcframeworkSnapshotting.xcframeworkPreviewsSupport.xcframeworkPreviewsSupportremains checked in atPreviewsSupport/PreviewsSupport.xcframeworkfor SwiftPM usage. The distribution build copies it intoXCFrameworks/so binary consumers and release assets use one artifact folder.Dynamic dependency model
Manual XCFramework integration does not get SwiftPM dependency resolution automatically, so consumers must link and embed the documented framework closure for each target.
The generated frameworks keep shared SnapshotPreviews dependencies as dynamic framework dependencies. This avoids duplicating shared support modules across frameworks when multiple SnapshotPreviews products are loaded in the same process.
Binary example project
Examples/DemoAppremains the normal local Swift Package example.Examples/DemoApp-XCFrameworksis the manual binary integration example. It shares source files from../DemoApp/..., links against../../XCFrameworks/*.xcframework, and includes a small wrapper script:cd Examples/DemoApp-XCFrameworks ./generate-xcframeworks.sh open DemoApp-XCFrameworks.xcodeprojShared demo source that depends on optional external packages uses
canImport, so the Swift Package example can keep accessibility snapshot rendering while the XCFramework example builds without that external package.Manual integration matrix
For an app target using per-preview rendering preferences:
SnapshotPreferences.xcframeworkSnapshotSharedModels.xcframeworkFor an app target using the gallery UI:
PreviewGallery.xcframeworkSnapshotPreviewsCore.xcframeworkSnapshotPreferences.xcframeworkSnapshotSharedModels.xcframeworkPreviewsSupport.xcframeworkFor an XCTest snapshot/layout target:
SnapshottingTests.xcframeworkSnapshotPreviewsCore.xcframeworkSnapshotSharedModels.xcframeworkPreviewsSupport.xcframeworkFor the inserted-dylib/accessibility runtime flow, also include:
Snapshotting.xcframeworkRefs EME-1168