It seems quite a bit depends on the broader picture of your setup. What versions are you using for:
- Xcode?
- Swift?
- CocoaPods?
- Firebase?
- Xcode Project Format?
- maybe others?
I ran into this same issue earlier this week, and my setup was the following:
- Xcode 13.3
- Swift 5
- CocoaPods 1.11.3
- Firebase/Analytics (8.12.1)
- Firebase/Core (8.12.1)
- Firebase/Crashlytics (8.12.1)
- FirebasePerformance (8.12.0)
- Xcode Project Format 3.2-compatible
When I went to build (for sim or device, didn't matter) I was getting Cannot find 'FirebaseApp' in scope
as an error. I literally did what Google says to do: https://firebase.google.com/docs/database/ios/start#set_up
import Firebase
...put the above in AppDelegate.swift
and run FirebaseApp.configure()
in this method
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
Didn't work.
As an experiment, I tried having FirebasePerformace
, FirebaseAnalytics
, and FirebaseCrashlytics
code all over my app, but didn't run Firebase.configure()
in the app delegate.
It compiled and ran!... but crashed when the app encountered some metrics capturing code from one of the above Firebase modules. So, clearly, the pod install
worked and is fine... So it wasn't a CocoaPods issue for me.
It then seemed to me that something was awry with what was being import
ed. The import Firebase
statement alone (as they claim) wasn't doing what it was supposed to do.
So, what did I try? Well, having used Firebase in the past, at one point, Google recommended using import FirebaseCore
. So that's what I did.
import FirebaseCore
I put the above line of code in my AppDelegate.swift
file in addition to import Firebase
, and problem solved! It now builds and runs on sim and device.
I would also recommend looking into what @AshvinA and @SomeshKarthik did if you are using features for those specific modules under the Firebase paradigm.
Again, your solution maybe different depending on the version(s) of various aspects of your project setup.