安装 cloud_firestore 包后,在 Flutter 中的 iOS 模拟器上运行应用程序时出错

问题描述

在安装 pod update Firebase/Firestore 软件包后,在 iOS 模拟器上运行时,我什至尝试过 cloud_firestore 仍然出现以下错误

即使我已经多次尝试删除 Podfile.lock 和 Flutter clean 然后 Flutter run

注意

  1. Flutter 版本:Flutter 2.0.2

  2. Dart 2.12.1

    未能构建 iOS 应用程序 Xcode 构建的错误输出: ↳ ** 构建失败 **

    Xcode's output:
    ↳
        In file included from /Users/gwl/firebase_demo/ios/Pods/abseil/absl/base/internal/thread_identity.cc:26:
        In file included from /Users/gwl/firebase_demo/ios/Pods/abseil/absl/base/call_once.h:34:
        /Users/gwl/firebase_demo/ios/Pods/abseil/absl/base/internal/invoke.h:42:10: Fatal error: 'absl/Meta/type_traits.h' file not found
        #include "absl/Meta/type_traits.h"
                 ^~~~~~~~~~~~~~~~~~~~~~~~~
        /Users/gwl/firebase_demo/ios/Pods/abseil/absl/base/internal/invoke.h:42:10: note: did not find header 'Meta/type_traits.h' in framework 'absl' (loaded from
        '/Users/gwl/firebase_demo/build/ios/Debug-iphonesimulator/abseil')
        1 error generated.
        note: Using new build system
        note: Building targets in parallel
        note: Planning build
        note: Constructing build description
    
    Could not build the application for the simulator.
    Error launching application on iPhone 11.
    

解决方法

你需要删除podfile.lock

然后你需要从 XCode 运行 iOS 文件夹来为你的项目加载资产

转到ios文件夹并执行pod install,如果它不存在则执行pod init然后pod install

请尝试 Xcode -> Product -> Run

,

首先删除 podfile.lock 并按照以下步骤操作;

flutter clean
flutter pub get
cd ios
pod install
flutter run

如果不起作用,请检查您的颤振频道并将其更改为测试版。

flutter pub upgrade
flutter channel beta
flutter clean
cd ios
pod install
flutter run

您也可以在下面切换回稳定输入;

flutter channel beta
,

这解决了我的问题GitHub issue

尝试在您的 ios 目录中运行这些命令:

rm -rf Pods
rm -rf Podfile.lock
rm -rf ~/.pub-cache/hosted/pub.dartlang.org/
pod cache clean --all
flutter clean
flutter pub get
pod repo update
pod install