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

I have the same issue, and do not have the library there: Mac-Studio:Volumes MGW$ ls /usr/lib/swift libswiftCreateML.dylib libswiftShazamKit.dylib libswiftVirtualization.dylib libswiftIdentityLookup.dylib libswiftSoundAnalysis_Private.dylib playgrounds libswiftRemoteMirror.dylib libswiftSoundAnalysis.dylib

How do install the library? Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: DYLD 1 Library missing Library not loaded: /usr/lib/swift/libswiftWebKit.dylib Referenced from: <0A128AB5-ED39-36A9-8EC3-7231029D42D3> /Users/USER/Library/Developer/CoreSimulator/Devices/CA0B3CCD-BD38-4766-A17E-463632FFDD04/data/Containers/Bundle/Application/915B71DC-BD1F-412F-A5EA-62C2867FAEF1/Runner.app/Frameworks/flutter_inappwebview_ios.framework/flutter_inappwebview_ios Reason: tried: '/Library/Developer/CoreSimulator/Volumes/iOS_22E238/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftWebKit.dylib' (no such file), '/usr/lib/swift/libswiftWebKit.dylib' (no such file, not in dyld cache), '/Library/Developer/CoreSimulator/Volumes/iOS_22E238/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libswiftWebKit.dylib' (no such file) (terminated at launch; ignore backtrace)

Can I temporarily copy it into place from one of the other locations?

Mac-Studio:Volumes MGW$ cd /Library/Developer/CoreSimulator/Volumes
Mac-Studio:Volumes MGW$ ls
iOS_21A342	iOS_21E213	iOS_22A3351	iOS_22C150	iOS_22G86
iOS_21C62	iOS_21F79	iOS_22B81	iOS_22E238	tvOS_22L572
Mac-Studio:Volumes MGW$ find . -name libswiftWebKit.dylib -print
./iOS_21A342/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.0.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftWebKit.dylib
./iOS_22C150/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftWebKit.dylib
find: ./iOS_22C150/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.2.simruntime/Contents/Resources/RuntimeRoot/private/var/db/modelmanagerd: Permission denied
./iOS_21C62/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftWebKit.dylib
./iOS_22G86/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.6.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftWebKit.dylib
./iOS_22G86/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.6.simruntime/Contents/Resources/RuntimeRoot/System/Cryptexes/OS/usr/lib/swift/libswiftWebKit.dylib
find: ./iOS_22G86/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.6.simruntime/Contents/Resources/RuntimeRoot/private/var/mobile: Permission denied
find: ./iOS_22G86/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.6.simruntime/Contents/Resources/RuntimeRoot/private/var/db/modelmanagerd: Permission denied
./iOS_22E238/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.4.simruntime/Contents/Resources/RuntimeRoot/System/Cryptexes/OS/usr/lib/swift/libswiftWebKit.dylib
find: ./iOS_22E238/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.4.simruntime/Contents/Resources/RuntimeRoot/private/var/mobile: Permission denied
find: ./iOS_22E238/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.4.simruntime/Contents/Resources/RuntimeRoot/private/var/db/modelmanagerd: Permission denied
./iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftWebKit.dylib
./iOS_21F79/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftWebKit.dylib
./tvOS_22L572/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS 18.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftWebKit.dylib
find: ./tvOS_22L572/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS 18.5.simruntime/Contents/Resources/RuntimeRoot/private/var/mobile: Permission denied
find: ./tvOS_22L572/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS 18.5.simruntime/Contents/Resources/RuntimeRoot/private/var/db/modelmanagerd: Permission denied
./iOS_22B81/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.1.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftWebKit.dylib
find: ./iOS_22B81/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.1.simruntime/Contents/Resources/RuntimeRoot/private/var/db/modelmanagerd: Permission denied
./iOS_22A3351/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.0.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftWebKit.dylib
find: ./iOS_22A3351/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.0.simruntime/Contents/Resources/RuntimeRoot/private/var/db/modelmanagerd: Permission denied

NO apparently SIP prevents it:

Mac-Studio:Volumes MGW$ sudo cp -f "/Library/Developer/CoreSimulator/Volumes/iOS_22G86/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.6.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftWebKit.dylib" "/Library/Developer/CoreSimulator/Volumes/iOS_22E238/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/"
cp: /Library/Developer/CoreSimulator/Volumes/iOS_22E238/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftWebKit.dylib: Operation not permitted

Happening on 18.4 for me as well.

Using 18.6 worked for me.

Confirmed that when the iOS 18.6 simulator is installed it seems to fix general simulator usage (even on iOS 17 simulators). However, #Previews still do not work:

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

Xcode 16.4 iOS 18.5 simulator crashes for Apps requiring webkit
 
 
Q