错误:未加载库:iOS 版 Flutter 中的 @rpath/libswiftCore.dylib

Bil*_*der 9 ios swift flutter

我在 android studio 中使用 flutter 来构建我的 iOS 应用程序。我在 mac 上安装了XCode 13。我最近从 windows 转到了 mac。除了我的两个主要应用程序之外,我所有的迷你应用程序都可以在 iPhone 模拟器上正常运行。构建它们后,我的应用程序在启动时崩溃,崩溃报告给出以下错误:

Reason: tried: '/Users/bilalsaeed/Library/Developer/
Xcode/DerivedData/Runner-bnnvczalmzdqlyblquzaiyfkgjkk/Build/Products/Debug-iphonesimulator/libswiftCore.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/
Contents/Resources/RuntimeRoot/usr/lib/system/introspection/libswiftCore.dylib' (no such file), '/Users/bilalsaeed/Library/Developer/CoreSimulator/Devices/592E30C6-E9E2-4658-B317-FA2833682817/data/Containers/Bundle/Application/91C8C35A-210B-4B0C-896F-643FB5D82265/Runner.app/Frameworks/libswiftCore.dylib' (no such file), 
'/Users/bilalsaeed/Library/Developer/CoreSimulator/Devices/592E30C6-E9E2-4658-B317-FA2833682817/data/Containers/Bundle/Application/91C8C35A-210B-4B0C-896F-643FB5D82265/Runner.app/Frameworks/libswiftCore.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libswiftCore.dylib' (no such file)
Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /Users/bilalsaeed/Library/Developer/CoreSimulator/Devices/592E30C6-E9E2-4658-B317-FA2833682817/data/Containers/Bundle/Application/91C8C35A-210B-4B0C-896F-643FB5D82265/Runner.app/Runner
  Reason: tried: '/Users/bilalsaeed/Library/Developer/Xcode/DerivedData/Runner-bnnvczalmzdqlyblquzaiyfkgjkk/Build/Products/Debug-iphonesimulator/libswiftCore.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection/libswiftCore.dylib' (no such file), '/Users/bilalsaeed/Library/Developer/CoreSimulator/Devices/592E30C6-E9E2-4658-B317-FA2833682817/data/Containers/Bundle/Application/91C8C35A-210B-4B0C-896F-643FB5D82265/Runner.app/Frameworks/lib
swiftCore.dylib' (no such file), '/Users/bilalsaeed/Library/Developer/CoreSimulator/Devices/592E30C6-E9E2-4658-B317-FA2833682817/data/Containers/Bundle/Application/91
(lldb) 
Run Code Online (Sandbox Code Playgroud)

我已经看到这个解决方案但无法理解它。

将我视为使用 flutter 构建 iOS 应用程序的新手。

Jar*_*vář 10

经过长时间的搜索和测试,这个解决方案有效:

为了确保您的构建与包含 Swift 的工件兼容,请将“构建设置”>“始终嵌入 Swift 标准库”设置为YES

如果您使用 Swift 并针对 iOS 12.2.0 或更早版本进行构建,请将/usr/lib/swift添加到“构建设置”>“运行路径搜索路径”,以防止libswiftCore.dylib出现任何问题。

Xcode 预览

也许这会对您有所帮助!

  • 该解决方案的第二部分解决了我的问题,并结束了为期两天的修复搜索!谢谢! (4认同)
  • 将“/usr/lib/swift”添加到“构建设置”对我有用。Xcode 14.3。谢谢! (3认同)