André Junior
André Junior

Reputation: 234

Flutter Error: no such module 'GoogleMaps'

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?

Upvotes: 7

Views: 13046

Answers (7)

zx goh
zx goh

Reputation: 21

flutter clean
flutter pub get
cd ios
pod install

Upvotes: 0

karmelcorn
karmelcorn

Reputation: 597

Check that you are opening Runner.xcworkspace instead of Runner.xcodeproj in Xcode

Upvotes: 0

mfurkanbabur
mfurkanbabur

Reputation: 11

This problem is because you opened the project in the wrong directory in xcode. If you open it correctly and try it, the problem will be solved.

Note: Applies to Flutter projects.

Upvotes: 1

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)
      }
    }

Upvotes: 0

Abir Ahsan
Abir Ahsan

Reputation: 3049

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

Upvotes: 7

progNewbie
progNewbie

Reputation: 4832

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.

Upvotes: 5

jujka
jujka

Reputation: 1217

flutter pub get
cd ios
pod install
pod update

Upvotes: 6

Related Questions