flutter 升级到 3.3.9 后,代码编译报错,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
$ flutter run Launching lib/main.dart on iPhone in debug mode... Automatically signing iOS for device deployment using specified development team in Xcode project: 4XS4BW9489 Running Xcode build... └─Compiling, linking and signing... 7.6s Xcode build done. 35.3s (lldb) dyld[627]: Library not loaded: @rpath/libswiftCore.dylib Referenced from: <8B0D72DF-EF41-3748-B8B5-8EF789672FF7> /private/var/containers/Bundle/Application/89C785E1-48B5-4139-8D0B-F392A3865D0B/Runner.app/Runner Reason: tried: '/private/var/containers/Bundle/Application/89C785E1-48B5-4139-8D0B-F392A3865D0B/Runner.app/Frameworks/libswiftCore.dylib' (errno=2), '/private/var/containers/Bundle/Application/89C785E1-48B5-4139-8D0B-F392A3865D0B/Runner.app/Frameworks/libswiftCore.dylib' (errno=2), '/private/preboot/Cryptexes/OS@rpath/libswiftCore.dylib' (errno=2), '/private/var/containers/Bundle/Application/89C785E1-48B5-4139-8D0B-F392A3865D0B/Runner.app/Frameworks/libswiftCore.dylib' (errno=2), '/private/var/containers/Bundle/Application/89C785E1-48B5-4139-8D0B-F392A3865D0B/Runner.app/Frameworks/libswiftCore.dylib' (errno=2), '/usr/local/lib/libswiftCore.dylib' (errno=2), '/usr/lib/libswiftCore.dylib' (errno=2, not in dyld cache) * thread #1, stop reason = signal SIGABRT frame #0: 0x00000001e6efeebc -> 0x1e6efeebc: b.lo 0x1e6efeedc 0x1e6efeec0: pacibsp 0x1e6efeec4: stp x29, x30, [sp, #-0x10]! 0x1e6efeec8: mov x29, sp Target 0: (Runner) stopped. Installing and launching... 26.6s Error launching application on iPhone. |
解决方法就是在工程的 "Build Settings->Linking->Runpath Search Paths" 加上 "/usr/lib/swift" 。
如下图:
参考链接
Flutter IOS 运行时崩溃(dyld: Library not loaded: @rpath/libswiftCore.dylib&&reason: i