我正在尝试在我的Flutter应用中实现Google Maps。
我正在使用此版本:
google_maps_flutter: ^0.5.21+15
它可以在android上运行,但是在ios上尝试时构建失败。
我发现了这一点:
通常我的AppDelegate.swift看起来像这样:
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
但是当我使用它时,正如谷歌 map 插件所说,构建失败:
import UIKit
import Flutter
import GoogleMaps
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
GMSServices.provideAPIKey("YOUR KEY HERE")
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
我究竟做错了什么?
感谢您的帮助!
以防万一,这是我的pubspec yaml
cupertino_icons: ^0.1.2
firebase_core: ^0.4.3+1
firebase_auth: ^0.15.2
cloud_firestore: ^0.13.0+1
firebase_database: ^3.1.1
cloud_functions: ^0.4.1+6
firebase_messaging: ^6.0.9
firebase_storage: ^3.1.0
google_sign_in: ^4.1.0
flutter_facebook_login: ^3.0.0
geolocator: ^5.1.5
shared_preferences: ^0.5.6
url_launcher: ^5.4.1
rflutter_alert: ^1.0.3
font_awesome_flutter: ^8.5.0
flutter_picker: ^1.1.0
uuid: ^2.0.4
image_picker: ^0.6.2+3
path_provider: ^1.5.1
image: ^2.1.4
flutter_datetime_picker: ^1.2.8
intl: ^0.16.0
native_contact_picker: ^0.0.6
flutter_spinkit: ^4.1.1+1
transparent_image: ^1.0.0
connectivity: ^0.4.6+1
flare_splash_screen: ^3.0.0
algolia: ^0.1.7
http: ^0.12.0+2
avatar_glow: ^1.1.0
rxdart: ^0.22.2
auto_size_text: ^2.1.0
camera: ^0.5.7+2
video_player: ^0.10.5
story_view: ^0.11.0
image_crop: ^0.3.1
file_picker: ^1.4.3+1
pdf_viewer_plugin: ^1.0.0+2
flutter_background_geolocation: ^1.4.5
location_permissions: ^2.0.3
image_downloader: ^0.19.1
permission_handler: ^4.0.0
google_maps_flutter: ^0.5.21+15
这是我得到的错误:
/Users/kareldebedts/myapp/ios/Runner/AppDelegate.swift:7:17: error: method does not override any method from its superclass
override func application(
~~~~~~~~ ^
note: Using new build system
note: Planning build
note: Constructing build description
warning: Mapping architecture armv7 to i386. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'image_picker' from project 'Pods')
warning: Mapping architecture arm64 to x86_64. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'image_picker' from project 'Pods')
warning: Mapping architecture armv7 to i386. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'camera' from project 'Pods')
warning: Mapping architecture arm64 to x86_64. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'camera' from project 'Pods')
Could not build the application for the simulator.
Error launching application on iPhone 11 Pro Max.
最佳答案
您已在函数签名中将UIApplication.LaunchOptionsKey
替换为UIApplicationLaunchOptionsKey
。装回以修复错误