Post

Replies

Boosts

Views

Activity

Recommended / Canonical way to host remote (separate process) SwiftUI views.
I am building a tool that enables the user to write, auto-compile and interact with SwiftUI code (think something like a mini Xcode Canvas). Which so far works really well. The app is not sandboxed since it uses tools like swiftc and sourcekit-lsp. The obvious problem here is that since the 'Preview' part of the app is driven by arbitrary code a crash/hang there would lead to a termination of the whole app. I understand that there are some private apis like NSRemoteView or CALayerHost but I would like to avoid them if I can. From what I see reading other similar solutions IOSurface sharing + event forwarding might be the best solution. So my question is: Is there a proper or recommended way to achieve this? Meaning having a fully interactive SwiftUI view presented in my host app but running on a separate process? Any pointers to the right direction or examples or whatever could help me with this would be greatly appreciated.
4
0
149
2w
Could not find library with name ”/usr/lib/swift/libswiftWebKit.dylib“
Canvas Previews (targeting macOS) in both Xcode 16.4 & Xcode 26 fail to load, when the project imports a Swift package that imports and uses WebKit. I'm on macOS 15.5. Tried also to bring minimum targets of both the project and the package to 15.0. I see that there are some work-arounds for iOS simulator but nothing for the Mac. Anyone facing the same problem?
5
0
142
Jun ’25
Xcode 16 RC - Cannot add packages
When opening the package management sheet there is a loading indicator going forever preventing the button to be enabled. The window displays collections but not "Recently used" (which also loads indefinitely). Anyone else seeing this? Any way to clear Xcode preferences/caches for the manager?
8
8
2.2k
Sep ’24
SwiftUI (macOS) - Canvas cgContext is unusable (?)
I'm having this weird issue where context.withCGContext { ... always has a reference to something like this: <CGContext 0x...> (kCGContextTypeUnknown) and sure enough when trying to use it I get (the ellipsis are mine since the address is irrelevant):  invalid context 0x... If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable The same code works fine on iOS. The GraphicsContext works fine on both platforms. Is anyone else having this issue, or am I missing something obvious here? [macOS 12.4 - Tried both on Intel & M1]
1
0
642
May ’22