我正在尝试使用我的 M1 MacBook Air 访问我的 Firestore 实例,但没有成功。尝试通过 iOS 模拟器访问会得到以下响应:
2021-01-20 09:18:11.747682-0500 TestApp[81986:3364534] 7.4.0 - [Firebase/Firestore][I-FST000001] WatchStream (600000541718) Stream error: 'Unavailable: Network connectivity changed'
2021-01-20 09:18:11.748325-0500 TestApp[81986:3364534] 7.4.0 - [Firebase/Firestore][I-FST000001] Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: Network connectivity changed
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
奇怪的是,它确实连接过一次——尽管这是很多次以前的事了。它能够提取我拥有的小数据集的快照。但是,它再也没有连接过,即使我更改了数据,也没有任何反应。我假设是因为它被缓存了。
我可以通过模拟器访问 Safari 和网站,所以我不认为这是一个实际的网络问题。
看看我如何在下面调用 Firestore:
Firestore.firestore().collection("companies").getDocuments{(snapshot, error) in
if error == nil {
for document in snapshot!.documents {
let name = document.data()["name"] as? String
print(name)
}
} else {
print(error ?? "Unknown Error")
}
}
看看下面我的 Podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Sesame' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for Sesame
pod 'Firebase/Firestore', '7.4-M1'
pod 'Firebase/Storage', '7.4-M1'
target 'SesameTests' do
inherit! :search_paths
# Pods for testing
end
target 'SesameUITests' do
# Pods for testing
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
end
"Podfile" 26L, 654C
有什么想法可以解决这个连接问题吗?