由于线程构建失败,Flutter 在 iOS 上崩溃

Posted

技术标签:

【中文标题】由于线程构建失败,Flutter 在 iOS 上崩溃【英文标题】:Flutter crashes on iOS due to failing construction of a thread 【发布时间】:2021-12-30 23:17:55 【问题描述】:

我只是想调试我在 ios 上的 Flutter 应用中所做的一些更改。从 VS Code 启动它并收到以下错误:

libc++abi: terminating with uncaught exception of type std::__1::system_error: thread constructor failed: Resource temporarily unavailable
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001b928e964 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
->  0x1b928e964 <+8>:  b.lo   0x1b928e984               ; <+40>
    0x1b928e968 <+12>: pacibsp 
    0x1b928e96c <+16>: stp    x29, x30, [sp, #-0x10]!
    0x1b928e970 <+20>: mov    x29, sp
Target 0: (Runner) stopped.

据我了解以及在互联网上找到的内容,该应用程序无法创建线程。不幸的是,它并没有说明为什么会发生这种情况或谁在尝试创建线程。

我尝试了多种方法来减少引起的可能性:

使用过的模拟器 使用真实设备 flutter clean 重启 VS Code 重新启动 Mac 回滚我的代码更改 在设备上安装而不是调试

没有任何改变。错误仍然出现。没有机会在另一台 Mac 上运行它。

有人知道错误或有什么建议吗?

flutter doctor -v:

[✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-arm, locale en-DE)
    • Flutter version 2.5.3 at /Users/****/tools/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (5 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✓] android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/****/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.1, Build version 13A1030d
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.62.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.28.0

[✓] Connected device (3 available)
    • MyRealDevice (mobile) • 00008030-0001359001******            • ios            • iOS 15.1 19B74
    • iPhone 13 (mobile)  • 1D5FF828-1E37-4E2B-88E8-B2010FC5DB3E • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • Chrome (web)        • chrome                               • web-javascript • Google Chrome 96.0.4664.55

• No issues found!

【问题讨论】:

【参考方案1】:

通过检查 git 中的最新更改来解决它。反转文件Info.plist中的以下行后

    <key>UILaunchStoryboardName</key>
    <string>Main</string>

    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>

我仍然不明白为什么这会导致错误,但现在它消失了。

【讨论】:

以上是关于由于线程构建失败,Flutter 在 iOS 上崩溃的主要内容,如果未能解决你的问题,请参考以下文章

在 BigSur、XCode 12 上 Flutter iOS 构建失败

Flutter 构建在 iOS 上失败,但在 android 上工作

Flutter:iOS 构建失败

Flutter - iOS 构建失败

Flutter ios 构建失败 - Distill 因未知原因而失败

当我运行 flutter run 时,Flutter iOS 构建失败