Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

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?

Answered by HolgerDe in 844182022

This seems to be related to this problem for iOS Simulators: Xcode 16.4 iOS 18.5 simulator crashes for Apps requiring webkit

The crash only occurs when some specific methods are called on WKWebView and some other types. One workaround for iOS simulator was providing a path for libswiftWebKit.dylib via DYLD_FALLBACK_LIBRARY_PATH. I don't know how this would be done in Previews though.

When you say "import and uses WebKit" do you mean a package that merely does import WebKit in it? Or is there more involved?

I created a package that does import WebKit and shows an empty WKWebView in an NSViewRepresentable and it's previewing fine. Are you able to shrink this down to a small reproducer? I'd recommend filing a feedback and attaching diagnostics and a reproducer if you are able. We can take a look. This may be unique configuration issue that needs to be looked at more closely.

Observing the same with previews, targeting iOS. Missing ”/usr/lib/swift/libswiftWebKit.dylib“. Though this file is really not present in this location. The problem occurs in previews only, normal builds are OK.

This seems to be related to this problem for iOS Simulators: Xcode 16.4 iOS 18.5 simulator crashes for Apps requiring webkit

The crash only occurs when some specific methods are called on WKWebView and some other types. One workaround for iOS simulator was providing a path for libswiftWebKit.dylib via DYLD_FALLBACK_LIBRARY_PATH. I don't know how this would be done in Previews though.

Ah, adding DYLD_FALLBACK_LIBRARY_PATH to your scheme's executable environment propagates to previews. So this should work great! Let us know if it doesn't work around the issue for you.

Could not find library with name ”/usr/lib/swift/libswiftWebKit.dylib“
 
 
Q