Skip to content

[Feature] Add Xcode Preview support for OpenSwiftUI#829

Merged
Kyle-Ye merged 1 commit intomainfrom
feature/preview
Mar 18, 2026
Merged

[Feature] Add Xcode Preview support for OpenSwiftUI#829
Kyle-Ye merged 1 commit intomainfrom
feature/preview

Conversation

@Kyle-Ye
Copy link
Collaborator

@Kyle-Ye Kyle-Ye commented Mar 18, 2026

Summary

  • Fix Xcode Preview rendering by disabling waitingForPreviewThunks blocking
  • SwiftUI's PreviewsInjection.framework calls __previewThunksHaveFinishedLoading() via a two-level namespace binding targeting SwiftUI, so OpenSwiftUI's version is never invoked — causing graph instantiation to block indefinitely
  • Implement __previewThunksHaveFinishedLoading() to properly unblock graph hosts
  • Add PreviewShims.swift helper to bridge OpenSwiftUI views into #Preview via hosting controllers
Simulator

diagram

@augmentcode
Copy link

augmentcode bot commented Mar 18, 2026

🤖 Augment PR Summary

Summary: Fixes Xcode Preview rendering for OpenSwiftUI by avoiding a Preview-thunk wait that never unblocks due to SwiftUI’s two-level namespace binding.

Changes:

  • Disable `waitingForPreviewThunks` gating so `GraphHost.instantiateIfNeeded()` can instantiate graphs under Xcode Previews.
  • Implement `__previewThunksHaveFinishedLoading()` to flush any queued hosts and notify delegates when thunk loading completes.
  • Add an example `PreviewShims.swift` bridge that wraps OpenSwiftUI views in hosting controllers for use with `#Preview`.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.17%. Comparing base (ff8c99a) to head (503c3b8).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
Sources/OpenSwiftUICore/Graph/GraphHost.swift 0.00% 8 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #829       +/-   ##
===========================================
+ Coverage   13.83%   27.17%   +13.33%     
===========================================
  Files         630      667       +37     
  Lines       38173    42960     +4787     
===========================================
+ Hits         5283    11675     +6392     
+ Misses      32890    31285     -1605     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

PreviewsInjection.framework calls SwiftUI.__previewThunksHaveFinishedLoading()
via a library-specific GOT binding (two-level namespace) after loading preview
dylibs. OpenSwiftUI's version is never called since the binding targets SwiftUI
specifically. Disable the blocking gate and implement the full unblocking logic
for when OpenSwiftUI adds its own preview thunk system in the future.
@github-actions github-actions bot added enhancement New feature or request UX project UX related labels Mar 18, 2026
@Kyle-Ye Kyle-Ye changed the title Fix Xcode Preview rendering for OpenSwiftUI [Feature] Add Xcode Preview support for OpenSwiftUI Mar 18, 2026
@Kyle-Ye Kyle-Ye merged commit 993bbde into main Mar 18, 2026
9 checks passed
@Kyle-Ye Kyle-Ye deleted the feature/preview branch March 18, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request platform: iOS platform: macOS UX project UX related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant