首页 > 解决方案 > Flutter 无法用 IOS 模拟器构建应用

问题描述

我是 Flutter 的新手,我在我的 Macbook Pro 上设置了 Flutter。Xcode 11.3.1(11C505)

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.14.6 18G4032, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Android Studio (version 3.6)
[✓] IntelliJ IDEA Community Edition (version 2018.3.6)
[✓] VS Code (version 1.44.2)
[✓] Connected device (1 available)

• No issues found!

它适用于 Android 模拟器。但是,它不适用于IOS。

我尝试了“flutter clean”,但没有奏效。似乎 Xcode 端错误,但不知道该怎么做。

Launching lib/main.dart on iPhone 11 in debug mode...
Xcode build done.                                           57.2s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **
Xcode's output:
↳
    === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
    While building module 'Flutter' imported from /Users/hb2746ap/AndroidStudioProjects/test_app/ios/Runner/GeneratedPluginRegistrant.h:8:
    While building module 'UIKit' imported from /Users/hb2746ap/AndroidStudioProjects/test_app/ios/Flutter/Flutter.framework/Headers/FlutterAppDelegate.h:8:
    While building module 'Foundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
    In file included from <module-includes>:1:
    In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:109:12: error: attributes may not be specified on a category
    @interface NSArray<ObjectType> (NSArrayDiffing)
.........
Skipped
.........
  ~~~~~~~~^
    1 error generated.
    15 errors generated.
    In file included from /Users/hb2746ap/AndroidStudioProjects/test_app/ios/Runner/GeneratedPluginRegistrant.m:5:
    /Users/hb2746ap/AndroidStudioProjects/test_app/ios/Runner/GeneratedPluginRegistrant.h:8:9: fatal error: could not build module 'Flutter'
    #import <Flutter/Flutter.h>
     ~~~~~~~^
    16 errors generated.
Could not build the application for the simulator.
Error launching application on iPhone 11.
Exited (sigterm)

标签: iosxcodeflutter

解决方案


推荐阅读