Android Studio 无法运行 Xcode 模拟器

Posted

技术标签:

【中文标题】Android Studio 无法运行 Xcode 模拟器【英文标题】:Android Studio cannot run the Xcode Simulator 【发布时间】:2019-03-03 03:41:43 【问题描述】:

我正在尝试使用 Xcode iPhone Simulator 模拟我的 Flutter 应用程序,但出现此错误。在升级 android Studio 和 Xcode 之前,它运行良好。

Launching lib/main.dart on iPhone X 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/User/AndroidStudioProjects/my_app/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework':
    1) Target 'Runner' has copy command from '/Users/User/AndroidStudioProjects/my_app/ios/Flutter/Flutter.framework' to '/Users/User/AndroidStudioProjects/my_app/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: ignoring duplicated output file: '/Users/User/AndroidStudioProjects/my_app/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 X.

使用:

macOS 10.13.6 (17G65) Android Studio 3.2 Build #AI-181.5540.7.32.5014246,于 2018 年 9 月 18 日构建 Xcode 10.0 (10A255) Xcode 模拟器 10.0 (SimulatorApp-869.5 CoreSimulator-572.2)

【问题讨论】:

【参考方案1】:

应该固定在master频道

https://github.com/flutter/flutter/issues/20685#issuecomment-421511890

解决方法

有两种解决方法:

选项 1:使用旧版构建系统。 如 @gi097 所述,打开 ios/Runner.xcworkspace,并将构建系统更改为 Legacy Build System选项 2:使用新的 Xcode 10 构建系统。
    打开ios/Runner.xcworkspace 在项目导航器侧边栏中选择Runner 项目。 在主视图中,选择Runner 目标,然后选择Build Phases 选项卡。 展开Embed Frameworks 阶段并从嵌入式框架列表中选择Flutter.framework。 单击-Flutter.framework 从列表中删除(请务必保留 App.framework)。

【讨论】:

以上是关于Android Studio 无法运行 Xcode 模拟器的主要内容,如果未能解决你的问题,请参考以下文章