Search code examples
iosapple-silicon

Unable to connect to Firestore via iOS Simulator on Apple Silicon


I'm trying to access my Firestore instance using my M1 MacBook Air, with no luck. Trying to access via the iOS simulator gives the following response:

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.

The odd thing is that it did connect one time - although this was many times ago. It was able to pull a snapshot of the small dataset I had. However, it never connected again, and even when I changed the data, nothing happened. I'm assuming because it was cached.

I am able to access Safari and websites via the simulator, so I don't believe it's an actual network issue.

A look at how I'm calling Firestore below:

    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")
            }
        }

A look at my Podfile below:

# 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

Any ideas where I should look to fix this connection issue?


Solution

  • Answering my own question for any who may come across this - I "solved" this issue. I had to use my own iPhone and deploy the code to that device, where it ran fine. I suppose this is an iOS simulator bug, specifically on Apple Silicon right now.