Flutter:无法构建 iOS 项目

Posted

技术标签:

【中文标题】Flutter:无法构建 iOS 项目【英文标题】:Flutter: Cannot build iOS project 【发布时间】:2020-09-17 17:46:50 【问题描述】:

它是在 android 上运行的项目,但是当我尝试在 ios 上构建时,我无法做到,如果也遇到这个问题,请与我分享知识。对不起我的英语不好。

这里是日志文件:

Flutter 崩溃报告;请提交至https://github.com/flutter/flutter/issues。

命令

flutter build ios --release

异常

ProcessException: ProcessException: 进程异常退出: 命令行调用: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -list

2020-05-30 10:58:59.614 xcodebuild[22085:408139] 错误域 = NSCocoaErrorDomain 代码 = 3840“JSON 文本没有以数组或对象和允许未设置片段的选项开头。” UserInfo=NSDebugDescription=JSON 文本没有以数组或对象开头,并且允许未设置片段的选项。 xcodebuild:错误:无法读取项目“Runner.xcodeproj”。 原因:“Runner”项目损坏,解析错误无法打开。检查项目文件是否存在无效编辑或未解决的源代码管理冲突。

路径:/Users/itinternational/AndroidStudioProjects/shipping_driver/ios/Runner.xcodeproj 命令:/usr/bin/xcodebuild -list

#0      RunResult.throwException (package:flutter_tools/src/base/process.dart:172:5)
#1      _DefaultProcessUtils.run (package:flutter_tools/src/base/process.dart:322:19)
<asynchronous suspension>
#2      XcodeProjectInterpreter.getInfo (package:flutter_tools/src/ios/xcodeproj.dart:389:50)
#3      buildXcodeProject (package:flutter_tools/src/ios/mac.dart:108:78)
#4      BuildIOSCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:83:43)
#5      _rootRunUnary (dart:async/zone.dart:1192:38)
#6      _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#7      _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#8      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#9      Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#10     Future._completeWithValue (dart:async/future_impl.dart:526:5)
#11     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:36:15)
#12     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:298:13)
#13     ApplicationPackageStore.getPackageForPlatform (package:flutter_tools/src/application_package.dart)
#14     _rootRunUnary (dart:async/zone.dart:1192:38)
#15     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#16     _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#17     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#18     Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#19     Future._completeWithValue (dart:async/future_impl.dart:526:5)
#20     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:36:15)
#21     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:298:13)
#22     BuildableIOSApp.fromProject (package:flutter_tools/src/application_package.dart)
#23     _rootRunUnary (dart:async/zone.dart:1192:38)
#24     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#25     _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#26     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#27     Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#28     Future._completeWithValue (dart:async/future_impl.dart:526:5)
#29     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:36:15)
#30     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:298:13)
#31     IosProject.productBundleIdentifier (package:flutter_tools/src/project.dart)
#32     _rootRunUnary (dart:async/zone.dart:1192:38)
#33     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#34     _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#35     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#36     Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#37     Future._completeWithValue (dart:async/future_impl.dart:526:5)
#38     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:36:15)
#39     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:298:13)
#40     IosProject.buildSettings (package:flutter_tools/src/project.dart)
#41     _rootRunUnary (dart:async/zone.dart:1192:38)
#42     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#43     _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#44     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#45     Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#46     Future._completeWithValue (dart:async/future_impl.dart:526:5)
#47     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:36:15)
#48     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:298:13)
#49     XcodeProjectInterpreter.getBuildSettings (package:flutter_tools/src/ios/xcodeproj.dart)
#50     _asyncErrorWrapperHelper.errorCallback (dart:async-patch/async_patch.dart:86:61)
#51     _rootRunBinary (dart:async/zone.dart:1204:38)
#52     _CustomZone.runBinary (dart:async/zone.dart:1093:19)
#53     _FutureListener.handleError (dart:async/future_impl.dart:155:20)
#54     Future._propagateToListeners.handleError (dart:async/future_impl.dart:694:47)
#55     Future._propagateToListeners (dart:async/future_impl.dart:715:24)
#56     Future._completeError (dart:async/future_impl.dart:534:5)
#57     _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:43:15)
#58     _DefaultProcessUtils.run (package:flutter_tools/src/base/process.dart)
#59     _rootRunUnary (dart:async/zone.dart:1192:38)
#60     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#61     _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#62     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#63     Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#64     Future._completeWithValue (dart:async/future_impl.dart:526:5)
#65     Future.wait.<anonymous closure> (dart:async/future.dart:402:22)
#66     _rootRunUnary (dart:async/zone.dart:1192:38)
#67     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#68     _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#69     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#70     Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#71     Future._addListener.<anonymous closure> (dart:async/future_impl.dart:391:9)
#72     _rootRun (dart:async/zone.dart:1184:13)
#73     _CustomZone.run (dart:async/zone.dart:1077:19)
#74     _CustomZone.runGuarded (dart:async/zone.dart:979:7)
#75     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)
#76     _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#77     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
#78     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#79     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)

扑医生

[✓] Flutter (Channel stable, v1.17.2, on Mac OS X 10.15.5 19F96, locale en-KG)
    • Flutter version 1.17.2 at /Users/itinternational/Downloads/flutter
    • Framework revision 5f21edf8b6 (33 hours ago), 2020-05-28 12:44:12 -0700
    • Engine revision b851c71829
    • Dart version 2.8.3

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/itinternational/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

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

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (1 available)
    • iPhone SE (2nd generation) • 9AD7BC02-943F-44FE-A4E3-FED33FE669DE • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-5 (simulator)

• No issues found!

【问题讨论】:

尝试删除您的 ios 文件夹并运行 flutter create -i swift . 重新创建它。可能文件夹里面的东西坏了。 太棒了!我会将其发布为解决方案 【参考方案1】:

尝试删除您的 ios 文件夹并运行 flutter create -i swift . 重新创建它。可能文件夹里面的东西坏了。

【讨论】:

p.s:目录名应该跟在dart packages naming convention后面,不知道为什么,但是因为我的目录名以大写字母开头,所以报错了

以上是关于Flutter:无法构建 iOS 项目的主要内容,如果未能解决你的问题,请参考以下文章

Flutter:无法构建 iOS 项目

Flutter 无法仅在物理 iOs 设备中构建和运行 iOS 应用程序

Flutter:无法在 codemagic 上为 ios 构建

Flutter

Flutter 无法在 VS Code 上构建示例 iOS 应用程序

开始使用 Flutter 构建 Windows 桌面应用吧!