Flutter错误:没有名为'GoogleMaps'的模块

6

我正在为一个客户购买的项目工作。该项目是Fluxstore,一款用Flutter构建的电子商务应用。

我可以在Android上运行该项目(模拟器和设备) 。但是iOS无法运行。我遇到了以下错误:

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

我在互联网上查找了解决此问题的方案,但是没有任何方法可行。请问有人能帮助我吗?


你已经找到解决这个问题的方法了吗?如果没有,你尝试运行flutter clean了吗? - Nelson Jr.
你解决了这个问题吗?我也卡在这里了。 - Alpit Panchal
有没有解决这个问题的方法。我在这里遇到了同样的问题。 - Abu Saad Papa
5个回答

5

删除所有的pod文件。运行flutter clean。然后进入iOS文件夹并运行pod init。这将创建一个pod文件。

target 'Runner' do之前添加pod 'GoogleMaps'这行代码。

我分享我的pod文件代码。

# 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

4
flutter pub get
cd ios
pod install
pod update

1
请不要仅在答案中发布代码,还要提供解释您的代码是如何解决问题的。有解释的答案通常更有帮助,质量更高,也更有可能获得赞同。 - Roshin Raphel

4

您是否在 pubspec.yaml 中检查了项目是否仍在使用 google_maps?如果没有,那么您应该删除 AppDelegate.swift 中的两行代码(即导入 google_maps 和 GMSServices.provideAPIKey)。

这应该可以解决问题。


0
请确保在您的appdelgate.swift文件中导入Google地图。
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)
      }
    }

0

这个问题是因为你在 xcode 中打开了错误的目录项目。如果你正确地打开并尝试它,问题将得到解决。

注意:适用于 Flutter 项目。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接