How tamasjager/catalystpreviewfailure works
Project type and purpose
• This is a minimal Swift Package that demonstrates a SwiftUI preview failure on Mac Catalyst.
• It’s not a full-blown app or microservice: it’s a sample/demo project (an open-source “proof-of-concept” tool) for reproducing a bug.
File structure
• Top-level:
– .gitignore, Package.swift, README.md
– .swiftpm/xcode (Xcode workspace config for Swift Package)
• Sources/CatalystPreviewFailure/CatalystPreviewFailure.swift contains the demo code.
• No separate frontend/backend: it’s a single SwiftUI view in a Swift package.
README for insights
• Purpose: “Demonstrates Mac Catalyst SwiftUI preview failure when used in Swift Packages.”
• Steps to reproduce: open the Swift file, set run destination to Mac Catalyst, attempt preview.
• No explicit architecture section—focus is on integration between Xcode, SwiftPM, SwiftUI, and the Catalyst runtime.
Main components
a. Developer / Xcode IDE
b. Swift Package Manager (SPM)
c. CatalystPreviewFailure module (Swift package target)
d. SwiftUI Preview Engine
e. Mac Catalyst runtime
f. Underlying build system (LLVM/Clang toolchain)
Relationships and interactions
• Developer triggers “Resume Preview” in Xcode ➔
Xcode invokes SPM and the build system to compile the CatalystPreviewFailure target for Mac Catalyst.
• Build system returns an artifact (a Dynamic Framework or binary slice for Catalyst).
• Xcode passes that binary to the SwiftUI Preview Engine.
• SwiftUI Preview Engine attempts to load the view in the Mac Catalyst runtime sandbox.
• In this demo, the Preview Engine fails to render (bug).
Architectural and design principles
• Component-based: separate module (the Swift package) vs. host environment (Xcode + runtime).
• Build pipeline: source ➔ compile ➔ dynamic framework ➔ runtime ➔ Preview engine
• Integration points: SPM manifest (Package.swift), Xcode workspace, SwiftUI‐Catalyst compatibility layer.
Technologies and frameworks
• Swift Package Manager (Package.swift manifest)
• SwiftUI framework (for view and preview)
• Mac Catalyst (UIKit-on-macOS runtime)
• Xcode’s SwiftUI preview subsystem
• LLVM/Clang toolchain (build)
Detail over breadth
• Even though it’s a simple demo, break it down:
– Source file
– SPM manifest processing
– Build output (dynamic framework for Catalyst)
– SwiftUI preview injection
– Catalyst sandbox