我使用此包在我的 flutter 应用程序中实现了谷歌地图:https://pub.dev/packages/google_maps_flutter。它显示在 Android 模拟器中,但未显示在 ios 模拟器和实际的 ios 设备(我的 iphone)上
pubspec.yaml: google_maps_flutter:^2.6.1
AppDelegate.swift:
import UIKit
import Flutter
import GoogleMaps
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
GMSServices.provideAPIKey("XxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-9I")
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Podfile
# Uncomment this line to define a global platform for your project
platform :ios, '12.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
信息.plist
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Need Access location for find nearby store</string><key>NSLocationAlwaysUsageDescription</key>
<string>Need Access location for find nearby store</string><key>NSLocationUsageDescription</key>
<string>Need Access location for find nearby store</string><key>NSLocationWhenInUseUsageDescription</key>
<string>Need Access location for find nearby store</string><key>NSMicrophoneUsageDescription</key>
解决了我的设备(iPhone)中显示的这个问题
我有同样的问题,但它在 TestFlight 的发布模式下的设备上不起作用。我需要一些帮助,请