简体   繁体   English

Flutter iOS 构建卡在“正在运行 Xcode 构建”上

[英]Flutter iOS build is stuck on "Running Xcode Build"

I recently got a mac to be able to test the iOS applications I made with Flutter/Dart.我最近有一台 Mac 可以测试我用 Flutter/Dart 制作的 iOS 应用程序。 But when trying to transfer all my files to a Mac and try to test it, it gets on "Running Xcode Build."但是当尝试将我的所有文件传输到 Mac 并尝试对其进行测试时,它会出现“正在运行 Xcode 构建”。

I am importing 2 things in my pubspec.yaml file:我在我的 pubspec.yaml 文件中导入了 2 个东西:

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

In my podfile, which I was told to download on the google admobs documentation I have在我的 podfile 中,我被告知要在我拥有的 google admobs 文档中下载该文件

pod 'Google-Mobile_Ads_SDK"

My Flutter Doctors reads:我的 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.

And the change to my info.plist is: (The actual app ID is in my code, just didn't want to post it here)我的 info.plist 的更改是:(实际的应用程序 ID 在我的代码中,只是不想在这里发布)

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

If I were to create a new Flutter project from scratch, the given code runs perfectly fine.如果我要从头开始创建一个新的 Flutter 项目,那么给定的代码运行得非常好。 It is just when I try to import the files the project on my windows PC to my Mac.就在我尝试将 windows PC 上的项目文件导入我的 Mac 时。

I think a solution would be to create a new Flutter project and while creating import my files, but I am not sure how to do that.我认为一个解决方案是创建一个新的 Flutter 项目并在创建导入我的文件时,但我不知道该怎么做。 So at the moment, I created a new Flutter project, deleted all the files that comes loaded initially, then replaced them with my project files.所以此刻,我创建了一个新的 Flutter 项目,删除了所有最初加载的文件,然后用我的项目文件替换它们。

in my case, I use Firebase Firestore.就我而言,我使用 Firebase Firestore。

it doesn't stuck actually, but it takes waaaay too long to build in Xcode.它实际上并没有卡住,但是在 Xcode 中构建需要很长时间。 don't forget to improve iOS build times as per the official documentation in here不要忘记根据此处的官方文档改进 iOS 构建时间

Currently the Firestore iOS SDK depends on some 500k lines of mostly C++ code which can take upwards of 5 minutes to build in XCode.目前,Firestore iOS SDK 依赖大约 50 万行 C++ 代码,在 XCode 中构建可能需要 5 分钟以上的时间。 To reduce build times significantly, you can use a pre-compiled version by adding 1 line to your ios/Podfile inside your Flutter project.为了显着减少构建时间,您可以通过在 Flutter 项目中的 ios/Podfile 中添加 1 行来使用预编译版本。

please open that documentation to improve the build time, because the code maybe updated.请打开该文档以缩短构建时间,因为代码可能已更新。

after adding that 1 line on your iOS podfile, don't forget to do flutter clean before rebuild the project.在你的 iOS podfile 上添加那 1 行之后,不要忘记在重建项目之前做flutter clean the second time you build the project it should be faster ( around 5 minutes for my project )第二次构建项目时应该会更快(我的项目大约需要 5 分钟)

I had removed the external devices specifically external monitors attached to Mac.我已经移除了连接到 Mac 的外部设备,特别是外部显示器。 Then made the build.然后进行了构建。

My build time came from 10min on average to 0.5 to 2 min max.我的构建时间从平均 10 分钟到最多 0.5 到 2 分钟。

iOS(Build) IPA building was taking around 14456.14 Sec ie (more than 4 hrs ) after updating to the below version it was reduced to 2143.3 Sec ie (less than 40 mins ) iOS(构建)IPA 构建大约需要14456.14 秒(超过4 小时),在更新到以下版本后减少到2143.3 秒(不到40 分钟

  1. Changed From:更改自:

     environment: sdk: ">=2.7.0 <3.0.0"

    Changes To:更改为:

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

    Please follow https://dart.dev/null-safety/migration-guide请遵循https://dart.dev/null-safety/migration-guide

In My Experience, this first build indeed takes a long time - but after you run it once - the build time is reasonable.根据我的经验,第一次构建确实需要很长时间——但是在你运行一次之后——构建时间是合理的。

If your build is stuck on Running Xcode build..., try the solution below:如果您的构建卡在 Running Xcode build... 上,请尝试以下解决方案:

cd Project Folder > cd 项目文件夹 >

rm -R build rm -R 构建

rm.dart_tool rm.dart_tool

rm.packages rm.packages

rm -Rf ios/Pods rm -Rf ios/Pods

rm -Rf ios/.symlinks rm -Rf ios/.symlinks

rm -Rf ios/Flutter/Flutter.framework rm -Rf ios/Flutter/Flutter.framework

rm -Rf ios/Flutter/Flutter.podspec rm -Rf ios/Flutter/Flutter.podspec

pod cache clean --all pod 缓存清理 --all

cd ios > pod deintegrate cd ios > 吊舱解体

pod setup吊舱设置

arch -x86_64 pod install cd..拱 -x86_64 吊舱安装光盘..

flutter clean -v flutter 清洁-v

flutter pub get flutter 酒吧得到

flutter clean && flutter run flutter 清洁 && flutter 运行

If the above fails, clone the project again and flutter run.如果上述失败,请再次克隆项目并运行 flutter。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM