WKWebView based apps crash in today's Xcode 16.4 iOS 18.5 simulator with messages including:
"Library not loaded: /usr/lib/swift/libswiftWebKit.dylib"
and of the form
"/Users/yyy/Library/Developer/Xcode/DerivedData/zzz/Build/Products/Debug-iphonesimulator/libswiftWebKit.dylib' (no such file)"
This issue is tracked in WebKit's bug tracker: https://bugs.webkit.org/show_bug.cgi?id=293831
Copying two workarounds listed there:
At this time, there are some workarounds that developers can use for testing and debugging in iOS 18.5 simulator:
Option 1: Change your app's deployment target to iOS 18.4 or later.
Set
IPHONEOS_DEPLOYMENT_TARGET = 18.4
in build settings, or use Xcode's UI: Select the app's target in a xcodeproj file, then go to General > Minimum Deployments > iOS and set it to 18.4.Rebuild the app.
Option 2: Set DYLD_FALLBACK_LIBRARY_PATH in the app's run action. This will allow you to test in iOS 18.5 simulator while continuing to deploy to older OS versions.
Find the simulator runtime's path using
xcrun simctl list runtimes -v
. It will be a path like "/Library/Developer/CoreSimulator/Volumes/iOS_22F77/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.5.simruntime".Add "Contents/Resources/RuntimeRoot/System/Cryptexes/OS/usr/lib/swift" to this path.
In Xcode, navigate to the launch arguments pane of your app's scheme. (Product > Scheme > Edit Scheme > Run > Arguments). Add a "DYLD_FALLBACK_LIBRARY_PATH" environment variable, whose value is the path you computed. It will be something like this:
DYLD_FALLBACK_LIBRARY_PATH = /Library/Developer/CoreSimulator/Volumes/iOS_22F77/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.5.simruntime/Contents/Resources/RuntimeRoot/System/Cryptexes/OS/usr/lib/swift
- Run the app (no need to rebuild).
For what it's worth, WebKit's bug will be marked as resolved when the issue is fixed on WebKit's main branch, not when the fix is available in a new simulator runtime.