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 can confirm that I'm facing the same issue:

Library not loaded: /usr/lib/swift/libswiftWebKit.dylib

If you set "User Script Sandboxing" to "No" in the Build Settings and register the following script in the "Run Script" phase of Build Phases, the simulator will no longer crash in either Xcode 26 or Xcode 16.4.

if [ "$PLATFORM_DISPLAY_NAME" = "iOS Simulator" ]; then KEYWORD="iOS ${TARGET_DEVICE_OS_VERSION}" DYLD_FALLBACK_FRAMEWORK_PATH=$(xcrun simctl list devices -v | grep "$KEYWORD" | awk -F'[][]' '{print $2}') DYLD_FALLBACK_FRAMEWORK_PATH="${DYLD_FALLBACK_FRAMEWORK_PATH}/Contents/Resources/RuntimeRoot/System/Cryptexes/OS/usr/lib/swift/" LIBRARY_FILE="libswiftWebKit.dylib" ln -sf "${DYLD_FALLBACK_FRAMEWORK_PATH}/${LIBRARY_FILE}" "${BUILT_PRODUCTS_DIR}/${LIBRARY_FILE}" echo "👉Created an alias for ${LIBRARY_FILE}" fi

Xcode 16.4 iOS 18.5 simulator crashes for Apps requiring webkit
 
 
Q