我到处寻找如何在flutter桌面应用程序中包含谷歌地图的指南。我试着遵循iOS指南,但没有成功。我在macos/Runner
目录中的AppDelegate.swift中做了以下操作
import Cocoa
import FlutterMacOS
import GoogleMaps
@NSApplicationMain
class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
GMSServices.provideAPIKey("MY_API_KEY")
return true
}
}
但我总是得到以下错误
The following build commands failed:
CompileSwift normal x86_64 /Users/xxxxx/xxxxx/xxxxxx/xxxxx/macos/Runner/AppDelegate.swift
CompileSwift normal x86_64 /Users/xxxxxxx/xxxxxx/xxxxxx/xxxxxx/macos/Flutter/GeneratedPluginRegistrant.swift
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(3 failures)
Finished with error: Build process failed
插件google_maps_flutter仅适用于iOS和Android。它基于iOS和Android的原生SDK。据我所知,MacOS没有官方的谷歌地图SDK,因此不可能在flutter插件中实现它。