无法在 iOs 上启动 Android Studio 默认 "new flutter project"

Cannot launch Android Studios default "new flutter project" on iOs

我最近更新了系统的多个组件,此后 flutter iOS 构建不再有效。

我的计划是找出导致问题的库,我决定从一个干净的新项目开始,一个一个地添加我需要的库,直到它失败。问题是我什至无法在 iOs 模拟器(或在真实的 IPhone 上启动新创建的 Android Studio“new flutter project”。

我已添加登录 Xcode 13.2.1 - 无进一步更改。

我的系统在 macOS Monterey 12.2.1 上运行。

当我尝试启动这个“原始”应用程序时,输出是:

Launching lib/main.dart on iPhone 13 in debug mode...
Running Xcode build...
Xcode build done.                                            2.3s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    Writing result bundle at path:
        /var/folders/t1/l4k0xxn13vz_ngc05nvytsb40000gn/T/flutter_tools.Gg1WCD/flutter_ios_build_temp_dirCeOcFZ/temporary_xcresult_bundle

    While building module 'Foundation' imported from /Users/bernhardpiskernik/StudioProjects/test_20220214/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-dummy.m:1:
    In file included from <module-includes>:1:
    In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.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)
               ^
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:196:12: error: attributes may not be specified on a category
    @interface NSMutableArray<ObjectType> (NSMutableArrayDiffing)
               ^
    While building module 'Foundation' imported from /Users/bernhardpiskernik/StudioProjects/test_20220214/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-dummy.m:1:
    In file included from <module-includes>:1:
    In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91:143: error: function does not return NSString
    - (NSAttributedString *)localizedAttributedStringForKey:(NSString *)key value:(nullable NSString *)value table:(nullable NSString *)tableName NS_FORMAT_ARGUMENT(1) NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0));
                                                             ~~~~~~~~~~~~~~                                                                       ^                  ~
    While building module 'Foundation' imported from /Users/bernhardpiskernik/StudioProjects/test_20220214/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-dummy.m:1:
    In file included from <module-includes>:1:
    In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:8:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:103:48: note: expanded from macro 'NS_FORMAT_ARGUMENT'
            #define NS_FORMAT_ARGUMENT(A) __attribute__ ((format_arg(A)))
                                                          ^          ~
    While building module 'Foundation' imported from /Users/bernhardpiskernik/StudioProjects/test_20220214/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-dummy.m:1:
    In file included from <module-includes>:1:
    In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:49:
    In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSKeyValueCoding.h:8:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.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.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSOrderedSet.h:185:12: error: attributes may not be specified on a category
    @interface NSMutableOrderedSet<ObjectType> (NSMutableOrderedSetDiffing)
               ^
    While building module 'Foundation' imported from /Users/bernhardpiskernik/StudioProjects/test_20220214/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-dummy.m:1:
    In file included from <module-includes>:1:
    In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:56:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSMorphology.h:64:12: error: attributes may not be specified on a category
    @interface NSMorphology (NSCustomPronouns)
               ^
    While building module 'Foundation' imported from /Users/bernhardpiskernik/StudioProjects/test_20220214/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-dummy.m:1:
    In file included from <module-includes>:1:
    In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:130:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLSession.h:500:168: error: expected ')'
    - (void)readDataOfMinLength:(NSUInteger)minBytes maxLength:(NSUInteger)maxBytes timeout:(NSTimeInterval)timeout completionHandler:(void (^) (NSData * _Nullable_result data, BOOL atEOF, NSError * _Nullable error))completionHandler;
                                                                                          ^
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLSession.h:500:141: note: to match this '('
    - (void)readDataOfMinLength:(NSUInteger)minBytes maxLength:(NSUInteger)maxBytes timeout:(NSTimeInterval)timeout completionHandler:(void (^) (NSData * _Nullable_result data, BOOL atEOF, NSError * _Nullable error))completionHandler;
                                                                                          ^
    7 errors generated.
    /Users/bernhardpiskernik/StudioProjects/test_20220214/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-dummy.m:1:9: fatal error: could not build module 'Foundation'
    #import <Foundation/Foundation.h>
     ~~~~~~~^
    8 errors generated.
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order

    Result bundle written to path:
        /var/folders/t1/l4k0xxn13vz_ngc05nvytsb40000gn/T/flutter_tools.Gg1WCD/flutter_ios_build_temp_dirCeOcFZ/temporary_xcresult_bundle


Parse Issue (Xcode): Attributes may not be specified on a category
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:108:11

Parse Issue (Xcode): Attributes may not be specified on a category
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:195:11

Semantic Issue (Xcode): Function does not return NSString
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:90:142

Parse Issue (Xcode): Attributes may not be specified on a category
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSOrderedSet.h:111:11

Parse Issue (Xcode): Attributes may not be specified on a category
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSOrderedSet.h:184:11

Parse Issue (Xcode): Attributes may not be specified on a category
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSMorphology.h:63:11

Parse Issue (Xcode): Expected ')'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLSession.h:499:167

Parse Issue (Xcode): Could not build module 'Foundation'
/Users/bernhardpiskernik/StudioProjects/test_20220214/ios/Pods/Target%20Support%20Files/Pods-Runner/Pods-Runner-dummy.m:0:8

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

flutter doctor -v returns:

[✓] Flutter (Channel stable, 2.10.1, on macOS 12.2.1 21D62 darwin-x64, locale en-AT)
    • Flutter version 2.10.1 at /Users/bernhardpiskernik/Library/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision db747aa133 (5 days ago), 2022-02-09 13:57:35 -0600
    • Engine revision ab46186b24
    • Dart version 2.16.1
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/bernhardpiskernik/Library/Android/sdk/
    • Platform android-32, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

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

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

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)

[✓] Connected device (2 available)
    • iPhone 13 (mobile) • 32762AE5-1FA2-428D-98DD-998153C83A7E • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

我错过了什么?

事实证明,我更新了导致问题的 conda 基础环境中的某些内容。

A​​ conda deactivate 足以成功 run flutter.

为了使 运行 按钮再次工作,我必须通过在 .zshrc 中的 conda init 块后添加 conda config --set auto_activate_base false 并重新启动 MacBook 来禁用 conda 基础环境的自动启动。