【发布时间】:2021-08-06 15:18:40
【问题描述】:
我正在开发基于简单聊天的 Flutter 应用程序。我正在使用 Firebase Auth、Firebase 消息传递、Google 登录 和 Cloud Firestore。在 Android 中一切正常,但是当我在 iOS 环境中运行此应用程序时,我遇到了一些问题,例如,
" CocoaPods 的错误输出: ↳ 搜索检查失败:nil 的未定义方法“map”:NilClass 例外:运行 pod install 时出错“
我还安装了一个 cocoapod,但它无法正常工作,那时我还面临另一个问题,如下所述:-
" 不要忘记匿名化任何私人数据! 寻找有关 cocoapods/cocoapods 的相关问题... 搜索检查失败:未定义方法 `map' for nil: NilClass "
我还使用了一些解决方案,它是 Github 上的参考,但仍然无法正常工作。 ============== 参考文献:-
================ 这是我的 Flutter Doctor 回复:-
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.6, on macOS 11.0.1 20B50 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] Connected device (2 available)
• No issues found!
=================== 这是我的 pubspec.yaml:-
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
**google_sign_in: 4.4.3**
**firebase_auth: 0.15.4**
**cloud_firestore: ^0.13.5**
shared_preferences: ^0.5.6+3
**firebase_messaging: 6.0.13**
flutter_local_notifications:
http: ^0.12.2
==================== 这是我的 cocoapods 环境,也是 pod 文件
堆栈
CocoaPods : 1.10.1
Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
RubyGems : 3.1.4
Host : macOS 11.0.1 (20B50)
Xcode : 12.2 (12B45b)
Git : git version 2.23.0
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/
安装源
Executable Path: /usr/local/bin/pod
插件
cocoapods-deintegrate : 1.0.4
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-trunk : 1.5.0
cocoapods-try : 1.2.0
Podfile
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
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)
end
end
在这个 podfile 中,由于出现了我上面提到的一些问题,我已经删除了 pod。
我正在使用 macOS Big Sur 版本 - 11.0.1 在 Android Studio 版本 4.1 中进行开发并在 iPad(第 6 代)中测试该应用程序14.2 版。
谁能帮我解决我做错了什么?所以我可以进一步解决 iOS 中的这个错误。
提前谢谢你。
【问题讨论】:
-
试试这个,看看线程中的任何内容是否适合您。 github.com/CocoaPods/CocoaPods/issues/8425
-
好的,根据您发送的第一个链接,this issue is an issue with the error inspector in CocoaPods。这意味着我们首先必须检查您的 CocoaPods 设置是否正确,这意味着,如果可能的话,您是否可以编辑您的帖子以包含您的文件结构,以便我们可以查看哪些文件(例如 .ruby-version 和 .xcodeproj ) 你有,你可能会丢失哪些可能需要重新配置?我们需要先弄清楚 CocoaPods 的问题是什么,然后才能在代码中找到问题
-
@NisanthReddy - 感谢您回复我的请求。正如您之前提到的(github.com/CocoaPods/CocoaPods/issues/8425)链接,我尝试使用该解决方案,但仍然无法解决此问题。
-
@fabc - 感谢您回复我的帖子。因此,我一直在使用颤振,直到现在我开始使用颤振创建的默认项目文件。我没有在 Xcode for iOS 中做任何特定的事情。不过,如果你想向你展示我可以向你展示的文件,这些文件是由 Flutter 默认为 iOS 创建的。
-
拜托,我知道这可能看起来很傻,但有时即使是默认设置或某些自动化系统也会导致错误。
标签: ios firebase flutter google-cloud-firestore firebase-cloud-messaging