简体   繁体   English

Flutter 应用程序 - 错误,Xcode **构建失败**

[英]Flutter App - ERROR, Xcode **BUILD FAILED**

Here's my terminal output: I have tried to update Xcode but i still get the same error.这是我的终端输出:我尝试更新 Xcode,但仍然遇到相同的错误。 When i run flutter -doctor v it passes all cases, and theres a check-mark in every section.当我运行 flutter -doctor v 时,它会通过所有情况,并且每个部分都有一个复选标记。 I have tried to build with AndroidStudio and then from the terminal and in both cases got the same error.我尝试使用 AndroidStudio 构建,然后从终端构建,在这两种情况下都遇到了相同的错误。 AndroidStudio built with Nexus 6 API works fine, just having troubles with iOS building使用 Nexus 6 API 构建的 AndroidStudio 工作正常,只是在构建 iOS 时遇到问题

~/Doc/FlutterLearn ❯  cd first_app                                 Py anaconda3
~/Doc/F/first_app ❯ c                                              Py anaconda3
~/Doc/F/first_app ❯ flutter run                                    Py anaconda3
Launching lib/main.dart on iPhone 8 in debug mode...
Running Xcode build...
 ├─Assembling Flutter resources...                           5.6s
 └─Compiling, linking and signing...                         5.0s
Xcode build done.                                           12.4s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    While building module 'Flutter' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.h:8:
    While building module 'UIKit' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Flutter/Flutter.framework/
    Headers/FlutterAppDelegate.h:8:
    While building module 'Foundation' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/UIKit.fra
    mework/Headers/UIKit.h:8:
    In file included from <module-includes>:1:
    In file included from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/Foundatio
    n.framework/Headers/Foundation.h:10:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/Foundatio
    n.framework/Headers/NSArray.h:109:12: error: attributes may not be specified
    on a category
    @interface NSArray<ObjectType> (NSArrayDiffing)
               ^
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/Foundatio
    n.framework/Headers/NSArray.h:196:12: error: attributes may not be specified
    on a category
    @interface NSMutableArray<ObjectType> (NSMutableArrayDiffing)
               ^
    While building module 'Flutter' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.h:8:
    While building module 'UIKit' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Flutter/Flutter.framework/
    Headers/FlutterAppDelegate.h:8:
    While building module 'Foundation' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/UIKit.fra
    mework/Headers/UIKit.h:8:
    In file included from <module-includes>:1:
    In file included from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/Foundatio
    n.framework/Headers/Foundation.h:48:
    In file included from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/Foundatio
    n.framework/Headers/NSKeyValueCoding.h:8:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/Foundatio
    n.framework/Headers/NSOrderedSet.h:112:12: error: attributes may not be
    specified on a category
    @interface NSOrderedSet<ObjectType> (NSOrderedSetDiffing)
               ^
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/Foundatio
    n.framework/Headers/NSOrderedSet.h:187:12: error: attributes may not be
    specified on a category
    @interface NSMutableOrderedSet<ObjectType> (NSMutableOrderedSetDiffing)
               ^
    4 errors generated.
    While building module 'Flutter' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.h:8:
    While building module 'UIKit' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Flutter/Flutter.framework/
    Headers/FlutterAppDelegate.h:8:
    In file included from <module-includes>:1:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/UIKit.fra
    mework/Headers/UIKit.h:8:9: fatal error: could not build module 'Foundation'
    #import <Foundation/Foundation.h>
     ~~~~~~~^
    While building module 'Flutter' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.h:8:
    While building module 'UIKit' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Flutter/Flutter.framework/
    Headers/FlutterAppDelegate.h:8:
    While building module 'QuartzCore' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/UIKit.fra
    mework/Headers/UIView.h:10:
    In file included from <module-includes>:1:
    In file included from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/QuartzCor
    e.framework/Headers/QuartzCore.h:9:
    In file included from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/QuartzCor
    e.framework/Headers/CoreAnimation.h:10:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/QuartzCor
    e.framework/Headers/CATransform3D.h:12:9: fatal error: could not build
    module 'Foundation'
    #import <Foundation/NSValue.h>
     ~~~~~~~^
    While building module 'Flutter' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.h:8:
    While building module 'UIKit' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Flutter/Flutter.framework/
    Headers/FlutterAppDelegate.h:8:
    While building module 'QuartzCore' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/UIKit.fra
    mework/Headers/UIView.h:10:
    While building module 'OpenGLES' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/QuartzCor
    e.framework/Headers/CAEAGLLayer.h:7:
    In file included from <module-includes>:1:
    In file included from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/OpenGLES.
    framework/Headers/EAGLDrawable.h:8:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/OpenGLES.
    framework/Headers/EAGL.h:8:10: fatal error: could not build module
    'Foundation'
    #include <Foundation/Foundation.h>
     ~~~~~~~~^
    1 error generated.
    While building module 'Flutter' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.h:8:
    While building module 'UIKit' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Flutter/Flutter.framework/
    Headers/FlutterAppDelegate.h:8:
    While building module 'QuartzCore' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/UIKit.fra
    mework/Headers/UIView.h:10:
    While building module 'Metal' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/QuartzCor
    e.framework/Headers/CAMetalLayer.h:7:
    In file included from <module-includes>:1:
    In file included from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/Metal.fra
    mework/Headers/Metal.h:9:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/Metal.fra
    mework/Headers/MTLTypes.h:8:9: fatal error: could not build module
    'Foundation'
    #import <Foundation/Foundation.h>
     ~~~~~~~^
    While building module 'Flutter' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.h:8:
    While building module 'UIKit' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Flutter/Flutter.framework/
    Headers/FlutterAppDelegate.h:8:
    While building module 'QuartzCore' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/UIKit.fra
    mework/Headers/UIView.h:10:
    While building module 'Metal' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/QuartzCor
    e.framework/Headers/CAMetalLayer.h:7:
    While building module 'IOSurface' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/Metal.fra
    mework/Headers/MTLTexture.h:15:
    In file included from <module-includes>:3:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/IOSurface
    .framework/Headers/IOSurfaceObjC.h:15:9: fatal error: could not build module
    'Foundation'
    #import <Foundation/Foundation.h>
     ~~~~~~~^
    1 error generated.
    2 errors generated.
    4 errors generated.
    While building module 'Flutter' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.h:8:
    While building module 'UIKit' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Flutter/Flutter.framework/
    Headers/FlutterAppDelegate.h:8:
    While building module 'CoreImage' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/UIKit.fra
    mework/Headers/UIColor.h:13:
    In file included from <module-includes>:1:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/CoreImage
    .framework/Headers/CoreImage.h:9:9: fatal error: could not build module
    'Foundation'
    #import <Foundation/Foundation.h>
     ~~~~~~~^
    While building module 'Flutter' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.h:8:
    While building module 'UIKit' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Flutter/Flutter.framework/
    Headers/FlutterAppDelegate.h:8:
    While building module 'CoreImage' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/UIKit.fra
    mework/Headers/UIColor.h:13:
    While building module 'CoreVideo' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/CoreImage
    .framework/Headers/CIImage.h:10:
    In file included from <module-includes>:1:
    In file included from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/CoreVideo
    .framework/Headers/CoreVideo.h:29:
    In file included from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/CoreVideo
    .framework/Headers/CVPixelBuffer.h:462:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/CoreVideo
    .framework/Headers/CVPixelBufferIOSurface.h:26:10: fatal error: could not
    build module 'IOSurface'
    #include <IOSurface/IOSurfaceRef.h>
     ~~~~~~~~^
    1 error generated.
    2 errors generated.
    While building module 'Flutter' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.h:8:
    While building module 'UIKit' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Flutter/Flutter.framework/
    Headers/FlutterAppDelegate.h:8:
    While building module 'FileProvider' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/UIKit.fra
    mework/Headers/NSFileProviderExtension.h:15:
    In file included from <module-includes>:1:
    In file included from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/FileProvi
    der.framework/Headers/FileProvider.h:15:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/FileProvi
    der.framework/Headers/NSFileProviderDomain.h:8:9: fatal error: could not
    build module 'Foundation'
    #import <Foundation/Foundation.h>
     ~~~~~~~^
    1 error generated.
    While building module 'Flutter' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.h:8:
    While building module 'UIKit' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Flutter/Flutter.framework/
    Headers/FlutterAppDelegate.h:8:
    While building module 'UserNotifications' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/UIKit.fra
    mework/Headers/UNNotificationResponse+UIKitAdditions.h:10:
    In file included from <module-includes>:1:
    In file included from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/UserNotif
    ications.framework/Headers/UserNotifications.h:8:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/UserNotif
    ications.framework/Headers/NSString+UserNotifications.h:8:9: fatal error:
    could not build module 'Foundation'
    #import <Foundation/Foundation.h>
     ~~~~~~~^
    1 error generated.
    13 errors generated.
    While building module 'Flutter' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.h:8:
    In file included from <module-includes>:1:
    In file included from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Flutter/Flutter.framework/
    Headers/Flutter.h:54:
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Flutter/Flutter.framework/
    Headers/FlutterAppDelegate.h:8:9: fatal error: could not build module
    'UIKit'
    #import <UIKit/UIKit.h>
     ~~~~~~~^
    While building module 'Flutter' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.h:8:
    While building module 'CoreMedia' imported from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Flutter/Flutter.framework/
    Headers/FlutterTexture.h:8:
    In file included from <module-includes>:1:
    In file included from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/CoreMedia
    .framework/Headers/CoreMedia.h:15:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/CoreMedia
    .framework/Headers/CMFormatDescription.h:29:10: fatal error: could not build
    module 'CoreVideo'
    #include <CoreVideo/CoreVideo.h>
     ~~~~~~~~^
    1 error generated.
    15 errors generated.
    In file included from
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.m:5:
    /Users/snak3/Documents/FlutterLearn/first_app/ios/Runner/GeneratedPluginRegi
    strant.h:8:9: fatal error: could not build module 'Flutter'
    #import <Flutter/Flutter.h>
     ~~~~~~~^
    16 errors generated.
    note: Using new build systemnote: Planning buildnote: Constructing build
    description

Could not build the application for the simulator.
Error launching application on iPhone 8.
~/Doc/F/first_app ❯  

                                 took 24s Py anaconda3

Here's the output from flutter doctor :这是 flutter doctor 的输出:

~ ❯ flutter doctor -v                                                                  Py anaconda3
[✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.14.6 18G95, locale en-CA)
    • Flutter version 1.9.1+hotfix.6 at /Users/snak3/flutter
    • Framework revision 68587a0916 (3 months ago), 2019-09-13 19:46:58 -0700
    • Engine revision b863200c37
    • Dart version 2.5.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/snak3/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

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

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 41.1.2
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 39.0.4
    • Dart plugin version 192.7761

[✓] VS Code (version 1.40.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.6.0

[✓] Connected device (1 available)
    • iPhone 8 • EB666770-13C5-4CE6-B24A-657C875939A7 • ios •
      com.apple.CoreSimulator.SimRuntime.iOS-13-0 (simulator)

• No issues found!

EDIT : I have found a way to make it work momentarily.编辑:我找到了一种让它暂时起作用的方法。 I open Xcode and I build it it there and the Simulator runs, i then close Xcode and have the Simulator and build my app with VSCode.我打开 Xcode 并在那里构建它并运行模拟器,然后关闭 Xcode 并拥有模拟器并使用 VSCode 构建我的应用程序。 But how would I fix the terminal command errors?但是我将如何修复终端命令错误?

I had a similar issue (different errors, but all were about imports).我有一个类似的问题(不同的错误,但都是关于进口的)。

I managed to fix it eventually by upgrading cocoapods and cocoapods-core from version 1.9.3 to 1.10 .我最终通过将cocoapodscocoapods-core从版本1.9.3升级到1.10来修复它。

Hope this may help someone else facing the same issue.希望这可以帮助面临同样问题的其他人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM