How to: Add Firebase to SwiftUI 2 (2020)
Let’s open the Firebase Console first:
We need to open a new project or use an existing one. After entering the project, click “Add Application”. Simply choose iOS as the application platform. Then, download the plist file and put it inside Xcode Project.
Next, we need to add a PodFile in the Xcode Project Folder. You can use terminal to do this step.
$ Pod init
Now, you can see a new file called, “Podfile”.
After that, double click to open PodFile or enter the command.
$ open Podfile
Add the follow line inside target (iOS)
Note: Do not add it after ‘end’, Firebase only supports iOS/iPadOS at this moment.
Save and run.
$ pod install
After the installation successfully, you will see a new folder and two files.
Double click to open xcworkspace (you don’t need to open xcodeproj file anymore)
Using Firebase to SwiftUI is very easy. You just need to open xxxApp.swift (Shared) and add
Then, you need to initial the Firebase app by using
Try to build on your iPhone or iPad.
Once your app intial successfully, you can see the below message.
You will see the analytics on Firebase, e.g. number of users, etc. The statistic update will take some time, please wait ~24 hours.