在Flutter开发项目中APP想实现新功能,所以需要接入新的第三方插件,但是有些第三个的Dart SDK版本要求很高,所以不得不升级Flutter SDK。于是索性把FLutter SDK升级到最新的3.X.X版本,然后遇到了iOS运行时找不到Swift动态库的问题:
dyld[4083]: Library not loaded: @rpath/libswiftCore.dylib
Referenced from: <9E270ED6-633F-3B50-95FF-9714EDA68D6B> /Users/cyclonecat/Library/Developer/CoreSimulator/Devices/638BCD07-E6BD-4978-BA3C-A4F36DD2C849/data/Containers/Bundle/Application/EF9F975D-C9E7-4E8C-BF18-2599885B7833/Runner.app/Runner
Reason: tried: '/Users/cyclonecat/Library/Developer/Xcode/DerivedData/Runner-cthezlxggpeeajfjbmnhvhiwfscy/Build/Products/Debug-iphonesimulator/libswiftCore.dylib' (errno=2), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection/libswiftCore.dylib' (errno=2), '/Users/cyclonecat/Library/Developer/CoreSimulator/Devices/638BCD07-E6BD-4978-BA3C-A4F36DD2C849/data/Containers/Bundle/Application/EF9F975D-C9E7-4E8C-BF18-2599885B7833/Runner.app/Frameworks/libswiftCore.dylib' (errno=2), '/Users/cyclonecat/Library/Developer/CoreSimulator/Devices/638BCD07-E6BD-4978-BA3C-A4F36DD2C849/data/Containers/Bundle/Application/EF9F975D-C9E7-4E8C-BF18-2599885B7833/Runner.app/Frameworks/libswiftCore.dylib' (errno=2), '/Users/cyclonecat/Library/Developer/CoreSimulator/Devices/638BCD07-E6BD-4978-BA3C-A4F36DD2C849/data/Containers/Bundle/Application/EF9F975D-C9E7-4E8C-BF18-2599885B7833/Runner.app/Frameworks/libswiftCore.dylib' (errno=2), '/Users/cyclonecat/Library/Developer/CoreSimulator/Devices/638BCD07-E6BD-4978-BA3C-A4F36DD2C849/data/Containers/Bundle/Application/EF9F975D-C9E7-4E8C-BF18-2599885B7833/Runner.app/Frameworks/libswiftCore.dylib' (errno=2), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libswiftCore.dylib' (errno=2)
Library not loaded: @rpath/libswiftCore.dylib
Referenced from: <9E270ED6-633F-3B50-95FF-9714EDA68D6B> /Users/cyclonecat/Library/Developer/CoreSimulator/Devices/638BCD07-E6BD-4978-BA3C-A4F36DD2C849/data/Containers/Bundle/Application/EF9F975D-C9E7-4E8C-BF18-2599885B7833/Runner.app/Runner
Reason: tried: '/Users/cyclonecat/Library/Developer/Xcode/DerivedData/Runner-cthezlxggpeeajfjbmnhvhiwfscy/Build/Products/Debug-iphonesimulator/libswiftCore.dylib' (errno=2), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection/libswiftCore.dylib' (errno=2), '/Users/cyclonecat/Library/Developer/CoreSimulator/Devices/638BCD07-E6BD-4978-BA3C-A4F36DD2C849/data/Containers/Bundle/Application/EF9F975D-C9E7-4E8C-BF18-2599885B7833/Runner.app/Frameworks/libswiftCore.dylib' (errno=2), '/Users/cyclonecat/Library/Developer/CoreSimulator/Devices/638BCD07-E6BD-4978-BA3C-A4F36DD2C849/data/Containe
dyld config: DYLD_SHARED_CACHE_DIR=/Users/cyclonecat/Library/Developer/CoreSimulator/Caches/dyld/21G115/com.apple.CoreSimulator.SimRuntime.iOS-16-0.20A360 DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/cyclonecat/Library/Developer/Xcode/DerivedData/Runner-cthezlxggpeeajfjbmnhvhiwfscy/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/usr/lib/libRPAC.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib DYLD_FRAMEWORK_PATH=/Users/cyclonecat/Library/Developer/Xcode/DerivedData/Runner-cthezlxggpeeajfjbmnhvhiwfscy/Build/Products/Debug-iphonesimulator DYLD_FALLBACK_FRAMEWORK_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks DYLD_FALLBACK_LIBRARY_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib
(lldb)
通过百度找到了这遍dyld:Library not loaded: @rpath/libswiftCore.dylib文章,但不能解决。
后面又找到了下面的方法,成功解决这个问题。
在项目的TARGETS下Runner的Build Settings->Linking->Runpath Search Paths配置添加/usr/bin/swift
和/usr/lib/swift
,如下图:
然后成功运行。
参考文章:
dyld:Library not loaded: @rpath/libswiftCore.dylib(这个不适用Flutter)
Flutter ‘/usr/lib/libswiftCore.dylib‘ (no such file)
flutter各种问题