Flutter Error: no such module 'GoogleMaps'

Viewed 4693

I am working in a project bought by a client. The project is Fluxstore. A E-commerce built with Flutter.

I can run the project in Android (emulator and device=). But iOS doesn't run. I get this following error:

Launching lib/main.dart on iPhone 11 in debug mode...
Running pod install...
Running Xcode build...
Xcode build done.                                           138,6s
Failed to build iOS app
Could not build the application for the simulator.
Error launching application on iPhone 11.
Error output from Xcode build:
↳
** BUILD FAILED **


Xcode's output:
↳
/Users/user./projects/project/ios/Runner/AppDelegate.swift:3:8: error: no such module 'GoogleMaps'
import GoogleMaps
       ^
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description

I looked up on solutions for this issue in Internet but nothing works. Can somebody please help me?

4 Answers

delete all pod file. run flutter clean. then go to iOS folder and run pod init. It's create a pod file. Add pod 'GoogleMaps' this line here before target 'Runner' do

I share my pod file code

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
pod 'Firebase/Analytics'
pod 'GoogleMaps'
# add pods for any other desired Firebase products
# https://firebase.google.com/docs/ios/setup#available-pods

target 'Runner' do
  # Comment the next line if you don't want to use dynamic frameworks
  
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for Runner

end
flutter pub get
cd ios
pod install
pod update

Did you check in the pubspec.yaml if the project still uses google_maps? Because if not, then you should remove the two lines in the AppDelegate.swift. (The import of google_maps and the GMSServices.provideAPIKey.

This should solve the problem.

Ensure you import google map in your appdelgate.swift

import UIKit
import Flutter
import GoogleMaps //This line

    @UIApplicationMain
    @objc class AppDelegate: FlutterAppDelegate {
      override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
      ) -> Bool {
        GMSServices.provideAPIKey("MAP API KEY")
        GeneratedPluginRegistrant.register(with: self)
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
      }
    }
Related