Flutter is an open-source cross-platform mobile application framework made by Google. Many mobile application developers have adopted the framework and has been used to build some innovative applications likeÂ Google Ads,Â AliBaba,Â Hamilton Musical etc.
Let me go straight to the point. Today, i will be showing you how to connect your Flutter iOS application to use Firebase services like Authentication, Firebase Cloud Messaging, Database, Maps,Â Storage etc.
As a flutter developer, i must say, i experienced some difficulties while connecting my iOS application made with Flutter SDK to Google's Firebase for the first time so i decided to write this little piece to serve as a guide to anyone who may be experiencing issues connecting their Flutter iOS application to Firebase.
I will assume the application has been created using flutter create command.
Goto https://console.firebase.google.com to add your iOS project to Firebase, click on "Add Project", a dialog will be shown, enter the project name, accept the terms and click on "Create Project".
Wait till the project is created, you should see something like the screenshot below once the process is successful. Tap on continue.
Open the project in Xcode by running the following command (without quote) on your macOS terminal, "open ios/Runner.xcworkspace"
Follow the screenshot below to obtain the app's Bundle Identifier which will be used as iOS bundle ID while setting up the iOS project.
On your project's dashboard, click on the highlighted button to add your iOS application.
Fill the fields, the iOS bundle ID is the one you copied in the previous step. Enter the app nick name and you can skip the App Store ID since we have not launched our app on App store before.
Click on "Register app" to continue.
Download the GoogleService-Info.plist file, drag and drop the file to the Runner/Runner folder. Click next on Firebase console.
Open the ios/Podfile using your favourite editor and add pod 'Firebase/Core' as shown below.
Goto your macOS terminal change change the directory to your project's ios folder, and run "pod install".
On the Firebase console, click on Next and skip the "Add initialization code" step.
Run flutter clean, uninstall the app from the simulator or physical device (if you have run the app before). Restart the debug session by rebuilding the app, wait for some minutes (maximum of 10minutes) for the app to communicate to Firebase.
With the above steps, you will experience a stress-free connection of your Flutter iOS application with Firebase. You can now use any of the Firebase services on your mobile application.
If you have any question, feel free to ask using the comments section below.