【问题标题】:Flutter iOS build is stuck on "Running Xcode Build"Flutter iOS 构建卡在“正在运行 Xcode 构建”
【发布时间】:2020-01-16 20:41:35
【问题描述】:

我最近得到了一台 Mac,能够测试我使用 Flutter/Dart 制作的 iOS 应用程序。但是当尝试将我的所有文件传输到 Mac 并尝试对其进行测试时,它会出现“正在运行 Xcode 构建”。

我在我的 pubspec.yaml 文件中导入 2 个东西:

dependicies:
  flutter:
    sdk:
      cupertino_icons: ^0.1.2
      firebase_admob: ^0.9.0+10

在我的 podfile 中,我被告知在我拥有的 google admobs 文档中下载该文件

pod 'Google-Mobile_Ads_SDK"

我的 Flutter 医生写道:

[flutter] flutter doctor -v
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-US)
    • Flutter version 1.12.13+hotfix.5 at /Users/priscilla/Desktop/Temp/flutter
    • Framework revision 27321ebbad (5 weeks ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/priscilla/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /usr/bin/java
    ✗ Could not determine java version

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C504
    • CocoaPods version 1.8.4

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).

[✓] Connected device (1 available)
    • iPhone 11 Pro Max • 754DF0BD-203E-4A0A-B785-E92D4B1D9C38 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)

! Doctor found issues in 2 categories.

我的 info.plist 的更改是:(实际的应用程序 ID 在我的代码中,只是不想在这里发布)

<key>GADApplicationIdentifier</key>
<string>[APP_ID]</string>

如果我要从头开始创建一个新的 Flutter 项目,那么给定的代码运行得非常好。就在我尝试将 Windows PC 上的项目文件导入 Mac 时。

我认为一个解决方案是创建一个新的 Flutter 项目并在创建时导入我的文件,但我不知道该怎么做。所以此刻,我创建了一个新的 Flutter 项目,删除了所有最初加载的文件,然后将它们替换为我的项目文件。

【问题讨论】:

  • 尝试运行flutter clean,我不知道它是否会修复,但肯定会有所帮助
  • @Tizianoreica 我试过了,仍然卡在运行 xcode build
  • 你试过运行flutter clean和pod install吗?并重建?

标签: ios flutter dart


【解决方案1】:

我已经移除了外部设备,特别是连接到 Mac 的外部显示器。 然后进行构建。

我的构建时间从平均 10 分钟到最多 0.5 到 2 分钟。

【讨论】:

  • 这太荒谬了。从我的 Macbook 上拔下外部显示器可将编译时间从大约 750 秒减少到大约 25 秒。就像,为什么它甚至是相关的?
  • 我认为这可能是由于某些 gpu 分配或 cpu 分配问题。我不知道。虽然我不是专家:)
  • 您知道问题是否在 BigSur 更新之前出现?
  • Big Sur 于 11 月 12 日发布。我于 11 月 9 日发布。为了得到解决方案,我花了一些时间。因此,无论我怎么看,问题在大苏尔之前就已经存在。 ;)
  • 拔下外接显示器后,构建完成。
【解决方案2】:

就我而言,我使用 Firebase Firestore。

它实际上并没有卡住,但是在 Xcode 中构建需要很长时间。不要忘记根据here中的官方文档改进iOS构建时间

目前 Firestore iOS SDK 主要依赖于大约 500k 行 在 XCode 中构建可能需要 2-3 分钟以上的 C++ 代码。至 显着减少构建时间,您可以使用预编译版本 通过在 Flutter 项目中的 ios/Podfile 中添加 1 行。

请打开该文档以缩短构建时间,因为代码可能会更新。

在您的 iOS podfile 中添加该 1 行后,不要忘记在重建项目之前执行flutter clean。第二次构建项目应该更快(我的项目大约需要 3 分钟)

注意:

如果有错误,请确保文档中代码中的 pod :tag =&gt; 'X.X.X' 中的标签与您的 cloud_firestore 包版本相匹配。有时官方文档没有像here中的问题那样更新

【讨论】:

  • 对我来说就是这种情况。我虽然它被卡住了,但它是 Firestore 需要大量时间
【解决方案3】:

iOS(Build) IPA 构建大约需要 14456.14 秒,即(超过 4 小时)在更新到以下版本后它减少到 2143.3 秒 即(少于 40 分钟

  1. 更改自:

    environment:
    sdk: ">=2.7.0 <3.0.0"
    

    更改为:

    environment:
    sdk: '>=2.12.0 <3.0.0'
    
  2. 将整个项目更改为 Null-safety

    请关注https://dart.dev/null-safety/migration-guide

【讨论】:

    【解决方案4】:

    根据我的经验,第一次构建确实需要很长时间 - 但运行一次后 - 构建时间是合理的。

    【讨论】:

      猜你喜欢
      • 2021-05-01
      • 2020-12-05
      • 2022-07-18
      • 1970-01-01
      • 2020-11-01
      • 2014-07-12
      • 2015-10-15
      • 2022-01-09
      • 2021-11-21
      相关资源
      最近更新 更多