Unable to build flutter app with firebase auth in Xcode

Viewed 586

I'm building a flutter mobile application with firebase_auth to authenticate. It's run well on android. But when i'm try to build it on ios using xcode it gives me series of erros.

I have added the GoogleService-info.plist file inside Runner folder using xcode and added the Firebase.configure() code potion in AppDeligate.swift file. But still not working for me.

enter image description here

3 Answers

Actually if you are develop your iOS app with Flutter you cant build in Xcode. You have to build with Flutter.

flutter clean
flutter build ios

Then

Xcode -> Product -> Destination -> Any iOS Device

Xcode-> Product -> Scheme -> choose scheme -> Runner

Xcode-> Product -> Archive

Or

flutter clean
flutter build ipa

then

Xcode-> Product -> Archive

Running in Xcode

First make sure to run pod install in the ios directory: cd ios; pod install

Then in Xcode, clean (Command + Shift + K) & rebuild (Command + B).

Running using flutter cli

Flutter CLI will make sure to run pod install for you. So it should work just by runnning flutter run or flutter build

Xcode errors almost never have singular answers

Add the GoogleService-info.plist file into your Xcode project by right-clicking on any file inside the Runner folder within the file Navigator pane (select add files to project and then add the GoogleService-info.plist into the project). This process will make sure that the Xcode project sees the file.

Make sure you enable the internet permission in the project.

You can install and use the pod deintegrate tool (src); with that tool you will be able to easily reset your Pod environment. A Google search can also give you others ways to reset the cocoapod environment. After which you'd want to pod install to ensure you get the latest versions of everything.

Make sure you address the pod warnings that usually appear. They might ask you to change your debug configuration to the Pods.debug reference for example.

flutter build ios will create any flutter specific files that might be missing so running this command in terminal from your project root folder is a great idea.

Another often missed opportunity is to just go into your root project and dump the (ios, macos, android, etc.) folder completely. Then use flutter create . from the project root folder to recreate the iOS folder before running flutter build then doing the normal sequence of getting Xcode ready.

In Xcode:

  • Open the workspace file not the Project file (we should see both Runner and Pods in the screenshot provided and I don't see that in yours)
  • Ensure that the project is signed
  • On the Runner project change the debug configurations to the Pods.
  • Add the Google info file into the iOS folder
  • Add the Google info file into the project workspace from within Xcode

NOTE:

I expect to see the Pods Project when you open the Runner.xcworkspace file. If not, make sure you are opening the workspace file, close Xcode and regenerate the pods from the iOS folder using pod install or from the root folder run flutter build ios.

Pods Project

Related