Bet*_*bus 4 xcode ios firebase flutter flutter-dependencies
我是颤振环境中的新生儿。
我试图设置与我的应用程序的 Cloud Firestore 连接。我在 VSCode 上完成了大部分编码过程,但在实现 firestore 后,我尝试在 Xcode 中构建,因为我在 VSCode 上遇到了一些错误。
在 Xcode 12.5.1 中构建我的应用程序(我使用 Rosetta 打开)时,我收到此错误 构建应用程序时出错 - 找不到模块“cloud_firestore”
我已确保在 Podfile 或 Pubspec.yaml 文件中添加依赖项。
这是我的 podfile,这是我的 pubspec.yaml 依赖项pubspec.yaml 依赖项
我尝试过几件事,例如:
解体pod并重新安装pod(包括删除podfile.lock和pods目录并重新安装pod)
我已经尝试过flutter clean-> flutter pub get-> flutter build ios,但仍然导致相同的错误。
我已通过 Xcode 将 GoogleService-Info.plist 导入到我的 Runner 中,并仔细检查名称。
让我感兴趣的是,我还添加了 Firebase_auth 包,它工作得很好。查看仅在导入 Cloud Firestore 行中显示的错误
有谁知道如何解决这个错误?任何帮助将非常感激。太感谢了
Bet*_*bus 25
经过几天的尝试和错误,我终于找到了解决问题的方法。
因此,我注意到在构建 iOS 时可能会导致错误的几件事。
切勿手动运行该命令pod install。
不要将该行添加pod install Firebase到您的 podfile 中。相反,只需使用以下命令覆盖所有 Firebase 依赖项$FirebaseSDKVersion = '8.0.0'
不要忘记在 podfile 上指定您的 iOS 部署目标,并将其与 Runner.xcworkspace 文件上的部署目标相匹配(在运行程序和目标中)
因此,如果您已经有一个项目,那么我建议您执行以下步骤,因为这非常适合我:
删除 Pods 目录、/ios/podfile.lock 和 ios/Flutter/Flutter.podspec
跑步pod deintegrate
删除 DerivedData 文件夹中的所有内容..您可以运行rm -rf ~/Library/Developer/Xcode/DerivedData/*
跑步flutter clean
跑步flutter pub get
跑步flutter build ios。请注意,这也将运行该pod install命令。
关闭编辑器,然后在 XCode 上打开 Runner.xcworkspace 并运行 XCode。清理你的构建文件夹。如果有更新项目设置的选项,请接受它。
您可能会收到一些有关已弃用功能的警告,但就我而言,我的应用程序运行得很好。
我不知道为什么会发生这种情况的详细信息,但从我注意到的情况来看,Cocoapods 对于 ios 的一些 firebase 软件包有不同的版本..我希望有人可以解释一下..
--
注意事项:
如果在 XCode 上构建您的应用程序,然后flutter run在终端或 VSCode 上使用,您会收到一些警告,例如Class AMSupportURLConnectionDelegate is Implemented in Both . 因此,根据我的个人经验,我总是从 XCode 运行我的应用程序。
如果您使用 Google 登录,请按照此处的步骤操作,无需在 podfile 中添加任何内容。
作为参考,这是我的 podfile 内容。
# Uncomment the next line to define a global platform for your project
# platform :ios, '12.0'
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
$FirebaseSDKVersion = '8.0.0'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
end
Run Code Online (Sandbox Code Playgroud)
我希望这个对你有用!祝你好运!
| 归档时间: |
|
| 查看次数: |
10735 次 |
| 最近记录: |