3

I have a native iOS app which is integrating a flutter module for a few features. Now for a new feature, I need to integrate Google maps inside the flutter module.

The documentation says we need to add Google maps initialization code inside ios/Runner/AppDelegate.m, but in my case the whole .iOS folder is regenerated in each new build, and adding things there will only make it work if I run the flutter module independently. But when I integrate the flutter module with the iOS native app, I get a crash: Google Maps SDK for iOS must be initialized via [GMSServices provideAPIKey:...] prior to use even if I have this line in the native iOS AppDelegate.

What am I missing?

Zakaria
  • 1,040
  • 3
  • 13
  • 28

1 Answers1

0

Figured out how to solve this by initializing Google Maps library that is used in Flutter module in addition to the one used in the main app:

So in my code I had to add a Google Maps initializer method inside the Flutter module and I called it from appDelegate in the main app after the original Google Maps initializer.

Zakaria
  • 1,040
  • 3
  • 13
  • 28
  • This was a long time ago so you probably don't have the code anymore, but if you do it would be helpful if you posted the lines you are referring to :) – Joel Broström Aug 24 '22 at 12:04
  • 1
    @JoelBroström I didn't add any specific code, just the usual `GMSServices.provideAPIKey()` that I had to call twice: Once inside the main app delegate and the second time inside the other module that's launching flutter. I hope that clears it. – Zakaria Aug 24 '22 at 14:52
  • Hi @Zakaria can you please share your code. – mbakabilal Jun 21 '23 at 20:44