Skip to content

✨ Render stock SwiftUI previews with Vizzly - #351

Open
Robdel12 wants to merge 8 commits into
mainfrom
rd/swift-preview-sdk
Open

✨ Render stock SwiftUI previews with Vizzly#351
Robdel12 wants to merge 8 commits into
mainfrom
rd/swift-preview-sdk

Conversation

@Robdel12

@Robdel12 Robdel12 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Why

SwiftUI teams already describe important UI states with stock #Preview declarations. Vizzly should be able to render those states directly instead of asking teams to maintain a second preview API or catalog.

What changed

  • Adds the @vizzly-testing/swift CLI plugin and vizzly previews command.
  • Builds the real iOS app, discovers generated preview registries, renders each preview in a booted Simulator, and writes PNGs plus a versioned manifest.
  • Auto-selects the project, shared scheme, and Simulator only when there is one safe choice. Ambiguous cases require an explicit value.
  • Sends captured previews to a live local TDD session or a Vizzly cloud build, with an intentional local-only fallback.
  • Exposes an isolated screenshot client through the stable plugin API so plugins can use the existing screenshot server without shared client state.
  • Protects managed output from incomplete, changed, duplicate, or unrelated files before replacing it.
  • Packages the preview plugin with the Swift client and exercises the native fixture in the Swift release workflow.
  • Rewrites the Swift docs around two clear paths: XCTest screenshots and stock SwiftUI preview capture.

Compatibility

The native renderer currently supports Xcode 26.6, arm64 iOS Simulators, iOS 17 or newer, scene-based apps, Debug builds, and previews without traits. The command checks the Xcode version and fails closed because preview interception depends on that release's Swift ABI.

Confidence

  • The fixture discovers and captures both stock previews twice with stable image hashes, then proves changed and missing managed artifacts are refused.
  • The complete Node test suite, Swift package tests, type tests, lint, format, CLI build, and npm tarball checks pass on the release Node 22 line.
  • The Swift SDK uploads real PNGs through a temporary local TDD server and verifies a repeated screenshot against its baseline.

Render existing stock #Preview declarations from the built app target through a Simulator-injected Swift runtime. Add the Vizzly CLI plugin, two-preview fixture, manifest output, and repeatable end-to-end coverage.
Select the device automatically when exactly one available iOS Simulator is booted. Keep ambiguous and stale-device cases explicit, actionable, and covered by the real preview capture path.
Harden the native renderer for real app targets, repeatable output, scheme selection, capture timeouts, and explicit compatibility failures. Ship the npm plugin through Swift releases, add CI coverage and complete fixture metadata, and verify package auto-discovery against a real iOS project.
Route native preview captures through the existing screenshot client for local TDD and cloud builds. Record upload outcomes, preserve explicit local-only capture, and cover the real HTTP boundary plus stock-preview naming and metadata.
Tighten managed output and plugin capability checks, run the native preview fixture during Swift releases, and replace duplicated Swift docs with focused XCTest and #Preview guides.
Move preview capture to a normal dynamic Swift Package dependency so Xcode owns building, embedding, and signing the runtime. Remove CLI injection and app mutation, add setup diagnostics, and prove the public integration on Simulator and device builds.
The macos-latest label moved to macOS 26, which no longer includes Xcode 16.2 or 16.4. Keep the existing compatibility matrix on the macOS 15 arm64 image where both toolchains are installed.
Scope the existing metric suppressions to the next class or method so the latest RuboCop no longer rejects the directive pairs. Ruby behavior and test coverage remain unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant