Xcode 16.2 runs well, but encountered the problem in Xcode 16.3.
Crash on "Library not loaded: /usr/lib/swift/libswiftWebKit.dylib" when use XCode 16.3, iOS 18.4
Thank you for sharing your post. To assist you further, could you please provide additional information regarding the issue with the library not loading? Specifically, please include all the logs generated by Xcode before and after the Library not loaded
error occurs. Additionally, if possible, please create a simple, focused project that demonstrates the issue.
Do you get the same results with just the relevant code in a small test project? If so, please share a link to your test project. That'll help us better understand what's going on. If you're not familiar with preparing a test project, take a look at Creating a test project.
Albert Pascual Worldwide Developer Relations.
Hi Albert,
dyld: Library not loaded: /usr/lib/swift/libswiftWebKit.dylib What I noticed: In iOS 18.4, libswiftWebKit.dylib now exists under: .../iOS18.4.simruntime/Contents/Resources/RuntimeRoot/System/Cryptexes/OS/usr/lib/swift/ But dyld doesn't seem to look there, and all fallback paths fail. In older runtimes (iOS 16.x, 17.x), the library is in the expected location, and apps run without issue. You can also check via: find /Library/Developer/ -name libswiftWebKit.dylib 2>/dev/null where the Packages were previous located :)
Steps to Reproduce:
- Use Xcode 16.3 on macOS 15.4.
- Run a Swift app (e.g., using WKWebView) on the iOS 18.4 simulator.
- App crashes at launch with the missing libswiftWebKit.dylib error.
Expected Result:
Simulator finds and loads libswiftWebKit.dylib properly.
Actual Result:
App crashes with dyld error; library not found.
Environment:
- macOS 15.4 (24E214)
- Xcode 16.3
- Simulator: iOS 18.4 (22E238)
- Apple Silicon M1 Max
Workarounds attempted:
- Simulator reset
- Reinstalling Command Line Tools
- Switching simulator runtimes (works fine with iOS 16.2–17.4)
- Attempting to symlink manually (blocked by system protections)
Can confirm this is also happening to us, using the simulator with iOS 18.3.1 works though.
We are seeing this as well. The issue does not occur on iOS 18.2 simulator, but does occur on iOS 18.4 simulator. This simulator is available in Xcode 16.3, but may not be related to the Xcode version per se.
Thanks for the reply. This is really interesting, can I ask you to submit a bug to us?
Once you open the bug report, please post the FB number here for my reference.
If you have any questions about filing a bug report, take a look at Bug Reporting: How and Why?
Albert Pascual Worldwide Developer Relations.
We bumped into similar issue, reported as FB17248284.
I have submitted the bug with the ID FB17250112.
The following workaround may help:
The path
/Library/Developer/CoreSimulator/Volumes/iOS_22E238/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.4.simruntime/Contents/Resources/RuntimeRoot/System/Cryptexes/OS/usr/lib/swift/libswiftWebKit.dylib
is actually a symlink to
/Library/Developer/CoreSimulator/Volumes/iOS_22E238/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.4.simruntime/Contents/Resources/RuntimeRoot/System/Cryptexes/OS/System/Library/Frameworks/WebKit.framework/WebKit
To resolve the issue, add a build phase that copies libswiftWebKit.dylib
(when the target is iphonesimulator and 18.4) into:
"$BUILT_PRODUCTS_DIR/libswiftWebKit.dylib"
Since BUILT_PRODUCTS_DIR
is one of the runtime search paths, the dylib gets correctly resolved and successfully loaded - allowing the app to launch without any problems.
Also seeing this issue and submitted a bug report FB17313505.
Also have the same issue. App works fine on real device with iOS 18.4 and emulators prior 18.4, but crashes on start with emulator 18.4
The issue is still reproducible in iOS Simulator 18.5 (22F77)
I'm running into the same issue. It doesn't happen if I just create a WKWebView. What triggers the crash is a call to evaluateJavaScript(_:in:in:completionHandler:)
or callAsyncJavaScript(_:arguments:in:in:completionHandler:)
on the web view, or their async counterparts. Here's a minimal reproducing example:
import SwiftUI
import WebKit
@main
struct LibswiftWebKitCrashApp: App {
var body: some Scene {
WindowGroup {
Text("Hello, world")
}
}
func thisIsNeverCalled() {
let webView = WKWebView()
webView.load(URLRequest(url: URL(string: "https://www.apple.com")!))
webView.callAsyncJavaScript("", in: nil, in: .page)
// webView.evaluateJavaScript("", in: nil, in: .page)
}
}
This shows "Hello, world" in an iOS 18.3.1 simulator, but crashes on launch in an iOS 18.4 or 18.5 (RC) simulator.
Environment: macOS 15.5 (24F74), Xcode 16.4 (16F6)
I'm going to file a Feedback later.
Feedback: FB17656597
I've also noticed similar to @dsyb that the crash occurs not simply when touching WKWebView, but specifically when calling evaluateJavaScript.
ChatGPT provided the following comment about this, which I cannot confirm:
This is exactly consistent with how Apple has recently started:
Pruning unused Swift overlay libraries more aggressively, And placing them behind version gates in dyld shared caches or dynamic linking rules.
Another thing that I've learned through testing is that if you set the minimum iOS target for your application to iOS 18.4 or higher that the problem goes away. In a sense you are breaking iOS 18.3 and below instead of 18.4 and above, but it works if you can bear to support only the very newest versions of iOS.
We're also seeing this: FB17747993