Swift development toolchain crashes in SwiftUI projects

When I try to run the Swift development toolchain in SwiftUI projects, it crashes with the following error.

dyld: Symbol not found: _$sSo12NSFileHandleC10FoundationE9readToEndAC4DataVSgyKF
Referenced from: /System/Library/Frameworks/SwiftUI.framework/SwiftUI
Expected in: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-01-04-     a.xctoolchain/usr/lib/swift/iphonesimulator/libswiftFoundation.dylib
in /System/Library/Frameworks/SwiftUI.framework/SwiftUI

Can anybody help me out?

Same problem here.

Looks like the toolchain Foundation doesn't include a method/function that SwiftUI relies on. Apple only guarantees that SwiftUI (which is an Apple-private framework) only works with Apple-sanctioned versions of its other frameworks, like Foundation, which on Darwin may be semi-private (parts open-source, parts proprietary to Apple). Swift development snapshots should be considered beta or alpha software. Most useful for command line tools, may be iffy when trying to mix with the release Apple ecosystem. You can probably get away with using the snapshot compiler, standard library, and the other tools, but frameworks like Foundation are going to be touch and go.

1 Like

I know it sounds counterintuitive, but deleting libswiftFoundation.dylib solved the issue for me:

rm /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-03-05-a.xctoolchain/usr/lib/swift/iphonesimulator/libswiftFoundation.dylib

Proof it's working: Using async/await in SwiftUI - YouTube

1 Like

Thank you for the workaround! I will check it out!

Terms of Service

Privacy Policy

Cookie Policy