在 Xcode 中存档时,Flutter Firestore 插件会抛出错误

Flutter Firestore plugin throws error when Archiving in Xcode

更新到最新版本的 cloud_firestore 插件后(参见下面的 pubspec.yaml),应用程序将不再存档在最新的 Xcode,尽管它 运行s 在模拟器上。

重现步骤

  1. 运行 flutter build ios --> 确定

    使用 Xcode 项目中的指定开发团队为设备部署自动签名 iOS:xxxxxx

    运行 pod 安装... 10,8s

    运行 Xcode 干净... 1,2s

    正在开始 Xcode 构建...
    ├─建立Dart代码... 23,5s ├─组装Flutter资源... 2,1s └─编译、链接和签名... 83,3s Xcode 构建完成。

  2. 在Xcode,Archive最终失败:

日志

While building module 'ProtoRPC' imported from /Users/sergebesnard/Development/Noteworthy/RoByN/app/ios/Pods/FirebaseFirestore/Firestore/Protos/objc/google/firestore/v1beta1/Firestore.pbrpc.h:21:
While building module 'GRPCClient' imported from /Users/sergebesnard/Library/Developer/Xcode/DerivedData/Runner-hizooagynttegaeqkhreoqwhrxzc/Build/Intermediates.noindex/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/gRPC-ProtoRPC/ProtoRPC.framework/Headers/ProtoRPC.h:20:
While building module 'RxLibrary' imported from /Users/sergebesnard/Development/Noteworthy/RoByN/app/ios/Pods/gRPC/src/objective-c/GRPCClient/GRPCCall.h:36:
In file included from <module-includes>:1:
/Users/sergebesnard/Development/Noteworthy/RoByN/app/ios/Pods/Target Support Files/gRPC-RxLibrary/gRPC-RxLibrary-umbrella.h:23:9: error: include of non-modular header inside framework module 'RxLibrary': '/Users/sergebesnard/Library/Developer/Xcode/DerivedData/Runner-hizooagynttegaeqkhreoqwhrxzc/Build/Intermediates.noindex/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/gRPC-RxLibrary/RxLibrary.framework/Headers/transformations/GRXMappingWriter.h' [-Werror,-Wnon-modular-include-in-framework-module]
#import "transformations/GRXMappingWriter.h"
        ^
1 error generated.
While building module 'ProtoRPC' imported from /Users/sergebesnard/Development/Noteworthy/RoByN/app/ios/Pods/FirebaseFirestore/Firestore/Protos/objc/google/firestore/v1beta1/Firestore.pbrpc.h:21:
While building module 'GRPCClient' imported from /Users/sergebesnard/Library/Developer/Xcode/DerivedData/Runner-hizooagynttegaeqkhreoqwhrxzc/Build/Intermediates.noindex/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/gRPC-ProtoRPC/ProtoRPC.framework/Headers/ProtoRPC.h:20:
In file included from <module-includes>:1:
In file included from /Users/sergebesnard/Development/Noteworthy/RoByN/app/ios/Pods/Target Support Files/gRPC/gRPC-umbrella.h:13:
In file included from /Users/sergebesnard/Development/Noteworthy/RoByN/app/ios/Pods/gRPC/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h:18:
/Users/sergebesnard/Development/Noteworthy/RoByN/app/ios/Pods/gRPC/src/objective-c/GRPCClient/GRPCCall.h:36:9: fatal error: could not build module 'RxLibrary'
#import <RxLibrary/GRXWriter.h>
 ~~~~~~~^
2 errors generated.
While building module 'ProtoRPC' imported from /Users/sergebesnard/Development/Noteworthy/RoByN/app/ios/Pods/FirebaseFirestore/Firestore/Protos/objc/google/firestore/v1beta1/Firestore.pbrpc.h:21:
In file included from <module-includes>:1:
In file included from /Users/sergebesnard/Development/Noteworthy/RoByN/app/ios/Pods/Target Support Files/gRPC-ProtoRPC/gRPC-ProtoRPC-umbrella.h:14:
/Users/sergebesnard/Library/Developer/Xcode/DerivedData/Runner-hizooagynttegaeqkhreoqwhrxzc/Build/Intermediates.noindex/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/gRPC-ProtoRPC/ProtoRPC.framework/Headers/ProtoRPC.h:20:9: fatal error: could not build module 'GRPCClient'
#import <GRPCClient/GRPCCall.h>
 ~~~~~~~^
3 errors generated.
In file included from /Users/sergebesnard/Development/Noteworthy/RoByN/app/ios/Pods/FirebaseFirestore/Firestore/Protos/objc/google/firestore/v1beta1/Firestore.pbrpc.m:17:
/Users/sergebesnard/Development/Noteworthy/RoByN/app/ios/Pods/FirebaseFirestore/Firestore/Protos/objc/google/firestore/v1beta1/Firestore.pbrpc.h:21:9: fatal error: could not build module 'ProtoRPC'
#import <ProtoRPC/ProtoService.h>
 ~~~~~~~^
4 errors generated.

flutter doctor -v ```

[✓] Flutter (Channel beta, v0.3.2, on Mac OS X 10.13.4 17E202, locale fr-BE)
    • Flutter version 0.3.2 at /Users/sergebesnard/Development/flutter
    • Framework revision 44b7e7d3f4 (4 weeks ago), 2018-04-20 01:02:44 -0700
    • Engine revision 09d05a3891
    • Dart version 2.0.0-dev.48.0.flutter-fe606f890b

[!] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at /Users/sergebesnard/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 27.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[✓] iOS toolchain - develop for iOS devices (Xcode 9.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 9.3.1, Build version 9E501
    • ios-deploy 1.9.2
    • CocoaPods version 1.5.0

[✓] Android Studio (version 3.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 24.2.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] VS Code (version 1.23.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Dart Code extension version 2.12.1

[✓] Connected devices (1 available)
    • iPhone X • 780C4B10-21A6-41E0-9A05-A6175FC20FA0 • ios • iOS 11.3 (simulator)

! Doctor found issues in 1 category.

可能与this issue

有关

Pubspec.yaml :

dependencies:


flutter:
    sdk: flutter
  google_sign_in: "^3.0.2"
  firebase_analytics: "^0.3.3"
  firebase_auth: "^0.5.10"
  firebase_database: "^0.4.6"
  firebase_storage: "^0.3.5"
  cloud_firestore: "^0.7.1"

这对我来说适用于具有引用依赖项的基于 Objective-C 的 Flutter 项目,而我可以使用基于 Swift 的项目进行重现。

Swift 错误消失,如果我修补其中一个 pod 伞头文件:

Pods/gRPC-RxLibrary/Support files/gRPC-RxLibrary-umbrella.h

---遵循https://www.bountysource.com/issues/40110207-swift-could-not-build-modules-during-archiving-and-include-of-non-modular-header-inside-framework-module-rxlibrary.

的建议

我遇到了同样的问题并注意到 flutter build 在使用 xcodebuild 构建时设置了 BUILD_DIR 标志 source root/build/ios (例如 xcodebuild BUILD_DIR=/Users/example/projects/flutter_app/build/ios ...) .我将它添加到我的归档命令中并且它起作用了。

¯\_(ツ)_/¯

gRPC 现在修复了在 xCode 中存档会崩溃的问题。如果您今天仍然遇到此问题,则表示您的 Pods 没有正确更新。

删除/ios/Podfile.lock和/ios/Pods

这就是我最终让 gRPC 加载到最新版本的方式。 gRPC 需要 1.13 或更高版本才能修复。

我发现了问题,所有部署目标都必须相同。也就是说,在项目文件中,目标和 pods' 项目也是如此。