iOS Xcode 10 的 Flutter 构建失败

Flutter build fails for iOS Xcode 10

我把 Flutter 升级到了最新的。以下是医生的输出

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.8.2, on Mac OS X 10.14 18A326h, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.1)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
[✓] Android Studio (version 3.1)
[✓] VS Code (version 1.27.1)

当我 运行 目标为 iOS 模拟器的应用程序时,我得到这个

Launching lib/main.dart on iPhone XS Max in debug mode...
Starting Xcode build...
Xcode build done.
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **

Xcode's output:
↳
    error: Multiple commands produce '/Users/kalehv/dev/todo/todo-flutter/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework':
    1) Target 'Runner' has copy command from '/Users/kalehv/dev/todo/todo-flutter/ios/Flutter/Flutter.framework' to '/Users/kalehv/dev/todo/todo-flutter/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework'
    2) That command depends on command in Target 'Runner': script phase “[CP] Embed Pods Frameworks”
    warning: The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for the "Runner" target. (in target 'Runner')
    warning: ignoring duplicated output file: '/Users/kalehv/dev/todo/todo-flutter/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework' (in target 'Runner')
    note: Using new build systemnote: Planning buildnote: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone XS Max.

我认为这至少对我有用 url

打开你的Xcode,在左上角Apple图标旁边有File,然后打开Workspace Settings并将构建系统更改为Legacy Build System

我遇到了同样的问题,但是当我更改为 Legacy Build System 时,我得到了很多 Apple Mach-O Linker Error

我最终将问题缩小到 Runner.xcodeproj/project.pbxproj 中的一个设置(可以从 XCode 中的 Runner -> Build settings 选项卡进行操作)。

我以某种方式设置了

Build active architecture only
           - Debug                   No
           - Profile                 Yes
           - Release                 Yes

将其更改为

Build active architecture only
           - Debug                   Yes
           - Profile                 Yes
           - Release                 Yes

解决了错误。

我通过在 ios 文件夹内的 Podfile 取消提交平台目标来解决这个问题,所以它将是 9。 然后你必须将平台目标从 Xcode 更改为 9 这很重要。 之后执行此操作 打开您的 Xcode,Apple 图标旁边的左上角有 File,然后打开工作区设置并将构建系统更改为 Legacy Build System

然后这样做 post link

点击 Xcode 和 运行 中的 clean 按钮项目。

希望对您有所帮助。