Flutter:项目无法在iOS模拟器上构建

7

尽管Flutter应用在Android模拟器、iOS和Android物理设备上从命令行运行成功,但是在iOS模拟器上构建失败。

这个问题出现在将Flutter版本从2.5.3升级到2.8.1后。

之前一切正常。

构建输出

This will generate a JSON format file containing all messages that 
need to be translated.
Launching lib/src/app/main_staging.dart on iPhone 13 in debug mode...
Running Xcode build...
Xcode build done.                                            3.0s
Failed to build iOS app
Error output from Xcode build:
↳
    xcodebuild: error: Unable to find a destination matching the provided destination specifier:
            { id:1DCE4D93-E8B4-40D1-BDC1-B8FA373B1961 }

        Ineligible destinations for the "staging" scheme:
            { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }

Could not build the application for the simulator.
Error launching application on iPhone 13.

这个模拟器也没有在Xcode中显示。
Flutter doctor输出:
flutter doctor -v 

[✓] Flutter (Channel stable, 2.8.1, on macOS 11.3.1 20E241 darwin-x64, locale en-GB)
    • Flutter version 2.8.1 at /Users/gohar.ali/Desktop/Flutter_dev/flutter
    • Upstream repository https://github.com/flutter/flutter.gitFramework revision 77d935af4d (3 weeks ago), 2021-12-16 08:37:33 -0800Engine revision 890a5fca2e
    • Dart version 2.15.1

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc3)
    • Android SDK at /Users/gohar.ali/Library/Android/sdk
    • Platform android-32, build-tools 31.0.0-rc3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/DeveloperCocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/ContentsFlutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutterDart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dartJava version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] Connected device (2 available)
    • iPhone (mobile) • 5d5629175f767d234062f6cfae22dc7bd3f5bc1b • ios            • iOS 14.7.1 18G82
    • Chrome (web)    • chrome                                   • web-javascript • Google Chrome 96.0.4664.110No issues found!

Xcode版本:13.2.1

模拟器中的iOS版本:15.2

非常感谢您的帮助。谢谢。


在Android Studio或模拟器中工作良好,但在Xcode中不起作用。 - Awais Rehman
只有模拟器有问题。我是从Android Studio运行的。同时也在Xcode中打开了项目,但模拟器没有出现在列表中。 - trigri
检查密钥链访问中的证书,有时在升级/更新Flutter时,证书会自行损坏。从密钥链中将其删除,并让Xcode创建一个新的证书。 - Gonzalo Ledezma Torres
我认为,如果这是一个证书问题,那我就不能为真实的iOS设备构建,对吗? - trigri
1个回答

28

也许这是一个解决方案:

在 XCode 的 "构建设置" 中查看并将 "支持的平台:iphoneos" 更改为 "支持的平台:iOS"。

在此输入图片描述


1
这个解决了问题。我还得运行 sudo gem uninstall cocoapods && sudo gem install cocoapods 然后重启 IDE。 - trigri
1
我遇到了相同的问题,但是我的Xcode项目中这个部分没有“支持的平台”选项。只有“目标设备系列”。 - Shaif Mohammad Reasat Dihan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接