Flutter iOS 在 BigSur 上构建失败,XCode 12

Flutter iOS build failing on BigSur, XCode 12

Flutter iOS 构建因 headers 问题而失败。

我按照 flutter.dev 中提到的简单步骤在 iOS 模拟器上启动应用程序。我在 Android/Web 上使用 flutter 没有遇到任何问题,但这是我第一次尝试 运行 在 iOS.

上使用它

错误摘要 -(完整错误:https://gist.github.com/mannprerak2/520f8a749431a50b8472783c71d67dda

...
   #import "Headers/CoreMedia.h"
            ^
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreMedia.framework/Headers/CoreMedia.h:15:10: note: in file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreMedia.framework/Headers/CoreMedia.h:15:
    #include <CoreMedia/CMFormatDescription.h>
             ^
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreMedia.framework/Headers/CMFormatDescription.h:26:10: error: could not build module 'CoreAudio'
    #include <CoreAudio/CoreAudioTypes.h>
             ^
    /Users/prerakmann/development/test_ios/ios/Runner/Runner-Bridging-Header.h:1:9: note: in file included from /Users/prerakmann/development/test_ios/ios/Runner/Runner-Bridging-Header.h:1:
    #import "GeneratedPluginRegistrant.h"
            ^
    /Users/prerakmann/development/test_ios/ios/Runner/GeneratedPluginRegistrant.h:8:9: error: could not build module 'Flutter'
    #import <Flutter/Flutter.h>
            ^
    192 errors generated.
    <unknown>:0: error: failed to emit precompiled header '/Users/prerakmann/Library/Developer/Xcode/DerivedData/Runner-ahrcvwuwhqnepxdcpfsagztcuwrr/Build/Intermediates.noindex/PrecompiledHeaders/Runner-Bridging-Header-swift_1QEOMJ6SUMBGB-clang_3BG5Q8JCTPBV5.pch' for bridging header '/Users/prerakmann/development/test_ios/ios/Runner/Runner-Bridging-Header.h'
    384 errors generated.
    <unknown>:0: error: generate-pch command failed with exit code 1 (use -v to see invocation)
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
...

系统:Macbook Pro 13 (2020), BigSur 11.2.1, Xcode 12.4

Flutter:已在最新的稳定版和 Beta 频道上试用。

模拟器:在 iOS 8、iOS 12 上试过。

重现步骤:新建一个flutter应用,运行它。

事实证明这是由于 CPATH 被这样定义而发生的。

╰─$ echo $CPATH
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include

临时修复是在当前终端 window 中设置 CPATH=,运行 flutter clean,然后 运行 应用程序。