Flutter 升級3.0后iOS運(yùn)行出現(xiàn)dyld[4083]: Library not loaded: @rpath/libswiftCore.dylib錯(cuò)誤

在Flutter開發(fā)項(xiàng)目中APP想實(shí)現(xiàn)新功能,所以需要接入新的第三方插件,但是有些第三個(gè)的Dart SDK版本要求很高,所以不得不升級Flutter SDK。于是索性把FLutter SDK升級到最新的3.X.X版本,然后遇到了iOS運(yùn)行時(shí)找不到Swift動態(tài)庫的問題:

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文章,但不能解決。
后面又找到了下面的方法,成功解決這個(gè)問題。
在項(xiàng)目的TARGETS下Runner的Build Settings->Linking->Runpath Search Paths配置添加/usr/bin/swift/usr/lib/swift,如下圖:

然后成功運(yùn)行。

參考文章:
dyld:Library not loaded: @rpath/libswiftCore.dylib(這個(gè)不適用Flutter)
Flutter ‘/usr/lib/libswiftCore.dylib‘ (no such file)
flutter各種問題

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容