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

Xcode 16.4 iOS 18.5 simulator crashes for Apps requiring webkit

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)"

Answered by Frameworks Engineer in 841589022

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.

  1. 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.

  2. 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.

  1. 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".

  2. Add "Contents/Resources/RuntimeRoot/System/Cryptexes/OS/usr/lib/swift" to this path.

  3. 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
  1. 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.

I'm facing the same issue. We have one file that "import WebKit" -- no manual linking is in place.

It ran fine on iOS 18.4/Xcode 16.3, but started crashing in Xcode 16.4/iOS 18.5

I'm facing the same issue, not it looks like I can't run the app on any simulator. Works fine if I run on device and from builds coming from Xcode Cloud, would love to know of a workaround so I can keep using the simulator 😭

In my case, importing WebKit and displaying WKWebViews works, but calling some specific APIs like createPDF triggers the exact same issue.

The only fix I found was changing the deployment target to 18.4 or 18.5, in the build settings of a duplicated Xcode configuration I use only to run my app in the simulator.

FB17731385 if anyone at Apple is reading this.

Greg de J. found a solution. Turns out this only happens if you call some of the WKWebView APIs, see: https://mastodon.social/@quicheindustries/114590816761623008

He found out that the issue came from calling WKWebView.createPDF. In my case, I was using WKWebView.createWebArchiveData, which also triggers the issue.

Until it's solved by Apple, the easiest fix is to compile out this code on the simulator using the #if !targetEnvironment(simulator) directive.

Changing my code to this, let's the app run on the simulator without issues:

#if !targetEnvironment(simulator)
    webView.createWebArchiveData { _ in }
#endif

It seems that the problem reaches into #Preview also - since #Preview seems to depend on the same missing libraries. I'm backing out of 16.4 for now, returning to 16.3 with its own set of problems - but at least I can simulate and preview.

Following up - and now back on Xcode 16.3 - including iOS 18.5 in the simulator: This works out really well as I can now #Preview, and simulate(iOS 18.5) without crashes, and build for TestFlight and deployment.

I'll wait awhile before I burn more hours trying to get Xcode 16.4 to behave.

I'm seeing the same crash here. Everything works fine on Xcode 16.3 with the iOS 18.4 Simulator.

We're also experiencing this exact crash. No problems on Xcode 16.3 with the 18.4 runtime.

Same thing here, this is fairly disruptive to our workflow as we have a workaround to set up the simulator project to have a min iOS version of 18.4.

Ditto: worked fine here with iOS 18.4 simulator built by Xcode 16.3.

Accepted Answer

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.

  1. 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.

  2. 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.

  1. 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".

  2. Add "Contents/Resources/RuntimeRoot/System/Cryptexes/OS/usr/lib/swift" to this path.

  3. 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
  1. 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.

I tested both options separately. Both worked. I really appreciate the rapid response. Sincere thanks.

For me the option 2 is not working (and option 1 is not really an option as we need to support older iOS versions). I followed the instructions, added the DYLD_FALLBACK_LIBRARY_PATH argument to the Run configuration of my scheme 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

But the app still crashed, and when it logs the dyld config, it prints this:

DYLD_FALLBACK_LIBRARY_PATH=/Library/Developer/CoreSimulator/Volumes/iOS_22F77/Library/Developer/CoreSimulator/Profiles/Runtimes/

So it seems my value for DYLD_FALLBACK_LIBRARY_PATH is just ignored.

I checked it a thousand times and don't understand what I'm doing wrong. Is this working for other people too?

Edit

Found the solution, see comments if you run into the same problem.

Option 2 seems to have a limitation where previews do not work. Is there a way to inject the DYLD_FALLBACK_LIBRARY_PATH into preview contexts?


    FailedToAnalyzeBuiltTargetDescription: Could not analyze the built target description for AppName to create the preview.
    
    buildableName: AppName
    
    ==================================
    
    |  CouldNotFindLibrary: Could not find library with name ”/usr/lib/swift/libswiftWebKit.dylib“

While Option 1 isn't really an option for the vast majority of companies, Option 2 doesn't work with Preview & Xcode Cloud.

As the variation on option 2 suggested here, one can use a Run Script Phase. The cons is that it will be dynamically switch to the run destination runtime (unless run without build is used with a different run destination).

if [ $XCODE_VERSION_ACTUAL -gt 1640 ]; then
    echo >&2 "error: time to remove 'libswiftWebKit' patch"
    exit 1
fi

DYLD_FALLBACK_LIBRARY_PATH=$(xcrun simctl list devices -v | awk -v device_uuid=$TARGET_DEVICE_IDENTIFIER '/^--/ { RUNTIME=$0 } $0 ~ device_uuid { print RUNTIME }' | sed -E 's/.*\[(.*)\].*/\1/')

DYLD_FALLBACK_LIBRARY_PATH="$DYLD_FALLBACK_LIBRARY_PATH/Contents/Resources/RuntimeRoot/System/Cryptexes/OS/usr/lib/swift"

ln -sf "$DYLD_FALLBACK_LIBRARY_PATH/libswiftWebKit.dylib" "$BUILT_PRODUCTS_DIR/libswiftWebKit.dylib"
Xcode 16.4 iOS 18.5 simulator crashes for Apps requiring webkit
 
 
Q