如何使用 Ionic 4 在 IOS 上修复“cordova-plugin-googlemaps 尚未安装或准备就绪”
Posted
技术标签:
【中文标题】如何使用 Ionic 4 在 IOS 上修复“cordova-plugin-googlemaps 尚未安装或准备就绪”【英文标题】:How to fix "cordova-plugin-googlemaps is not installed or ready yet" on IOS with Ionic 4 【发布时间】:2019-10-22 01:48:29 【问题描述】:我使用 GoogleMaps 在 Ionic 4 上开发了一个应用程序。我最初是在android上开发的,然后当我想将我的项目导出到ios时出现问题。
我想指出,我在 Android 上使用了 cordova-plugin-googlemaps“multiple_maps”版本,没有它我无法让地图在 Android 上运行。
我为我的项目安装了依赖项:
cordova 准备 ios npm install @ionic-native/core@beta npm install @ionic-native/google-maps@beta ionic cordova 插件添加 cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="my android key" --variable API_KEY_FOR_IOS="my IOS key"但是使用最后一个命令,问题出现了。我可以在控制台中看到 android 和浏览器安装得很好,ios 也感谢“pod”。 所以我试图在 Xcode 上构建:我有错误,找不到文件“GoogleMaps/GoogleMaps.h”。
我找到的解决方法是打开 Podfile 文件,将 GoogleMaps 的版本从默认的“2.7.0”更改为“3.1.0”版本。所以我删除了 Podfile.lock 文件和 Pods 文件夹,然后我重新启动了一个 pod 安装。
不幸的是,我仍然有错误“GoogleMaps/GoogleMaps.h is not found.”,但我曾经设法(不幸的是我不知道如何)删除了这个错误并启动了这个应用程序。
我有错误“[GoogleMaps] cordova-plugin-googlemaps 尚未安装或准备就绪”,而不是地图。 .我很确定它背后的代码没问题,因为它在 Android 上运行没有任何问题。
这是我的不同信息:
操作系统:Mojave 10.14.5(最新版本) XCode:10.2(最新版本) 科尔多瓦:8.1.2 科尔多瓦-ios:5.0.1 离子:5.0.1
我的cordova插件列表:
cordova-clipboard 1.2.1 "Clipboard"
cordova-plugin-camera 4.0.3 "Camera"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-filepath 1.5.1 "cordova-plugin-filepath"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-googlemaps 2.6.2 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 3.1.2 "cordova-plugin-ionic-webview"
cordova-plugin-mauron85-background-geolocation 3.0.3 "CDVBackgroundGeolocation"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
info.protonet.imageresizer 0.1.1 "Image Resizer"
我的 package.json
"dependencies":
"@angular/common": "^7.2.13",
"@angular/core": "^7.2.13",
"@angular/forms": "^7.2.13",
"@angular/http": "^7.2.13",
"@angular/platform-browser": "^7.2.13",
"@angular/platform-browser-dynamic": "^7.2.13",
"@angular/router": "^7.2.13",
"@ionic-native/splash-screen": "^5.4.0",
"@ionic-native/status-bar": "^5.4.0",
"@ionic/angular": "^4.3.0",
"@mauron85/cordova-plugin-background-geolocation": "3.0.3",
"cordova-android": "8.0.0",
"cordova-browser": "6.0.0",
"cordova-clipboard": "1.2.1",
"cordova-ios": "4.5.5",
"cordova-plugin-camera": "4.0.3",
"cordova-plugin-device": "2.0.2",
"cordova-plugin-file": "6.0.1",
"cordova-plugin-file-transfer": "1.7.1",
"cordova-plugin-filepath": "1.5.1",
"cordova-plugin-geolocation": "4.0.1",
"cordova-plugin-googlemaps": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps.git#multiple_maps",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^3.0.0",
"cordova-plugin-mauron85-background-geolocation": "^3.0.1",
"cordova-plugin-network-information": "2.0.1",
"cordova-plugin-splashscreen": "5.0.2",
"cordova-plugin-statusbar": "2.4.2",
"cordova-plugin-whitelist": "1.3.3",
"cordova-windows": "4.4.2",
"core-js": "^2.5.4",
"info.protonet.imageresizer": "0.1.1",
"ionic-plugin-keyboard": "2.2.1",
"zone.js": "~0.8.29"
,
"devDependencies":
"@angular-devkit/architect": "~0.12.3",
"@angular-devkit/build-angular": "^0.13.8",
"@angular-devkit/core": "~7.2.3",
"@angular-devkit/schematics": "~7.2.3",
"@angular/cli": "^7.3.8",
"@angular/compiler": "^7.2.13",
"@angular/compiler-cli": "^7.2.13",
"@angular/language-service": "^7.2.13",
"@fortawesome/angular-fontawesome": "^0.3.0",
"@fortawesome/fontawesome-free": "^5.8.1",
"@fortawesome/fontawesome-svg-core": "^1.2.17",
"@fortawesome/free-brands-svg-icons": "^5.8.1",
"@fortawesome/free-regular-svg-icons": "^5.8.1",
"@fortawesome/free-solid-svg-icons": "^5.8.1",
"@ionic-native/background-geolocation": "^5.4.0",
"@ionic-native/camera": "^5.5.1",
"@ionic-native/clipboard": "^5.4.0",
"@ionic-native/core": "^5.0.0",
"@ionic-native/file": "^5.5.1",
"@ionic-native/file-path": "^5.5.1",
"@ionic-native/geolocation": "^5.4.0",
"@ionic-native/google-maps": "^5.0.0-beta.27",
"@ionic-native/image-resizer": "^5.5.1",
"@ionic-native/keyboard": "^5.4.0",
"@ionic-native/network": "^5.6.0",
"@ionic-native/transfer": "^3.14.0",
"@ionic/angular-toolkit": "~1.4.0",
"@ionic/app-scripts": "^3.2.3",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~10.14.2",
"codelyzer": "~4.5.0",
"cordova": "^8.1.2",
"ionic4-rating": "^1.0.9",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.4",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"node-sass": "^4.12.0",
"protractor": "~5.4.0",
"rxjs": "^6.5.2",
"rxjs-compat": "^6.4.0",
"ts-node": "~8.0.0",
"tslint": "~5.12.0",
"typescript": "~3.1.6"
,
"description": "Test",
"cordova":
"platforms": [
"windows",
"browser"
],
"plugins":
"cordova-plugin-geolocation":
"GEOLOCATION_USAGE_DESCRIPTION": ""
,
"cordova-plugin-whitelist": ,
"cordova-plugin-statusbar": ,
"cordova-plugin-device": ,
"cordova-plugin-splashscreen": ,
"cordova-plugin-ionic-webview":
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
,
"cordova-plugin-ionic-keyboard": ,
"cordova-clipboard": ,
"cordova-plugin-mauron85-background-geolocation":
"GOOGLE_PLAY_SERVICES_VERSION": "11+",
"ANDROID_SUPPORT_LIBRARY_VERSION": "26+",
"ICON": "@mipmap/icon",
"SMALL_ICON": "@mipmap/icon",
"ACCOUNT_NAME": "@string/app_name",
"ACCOUNT_LABEL": "@string/app_name",
"ACCOUNT_TYPE": "$PACKAGE_NAME.account",
"CONTENT_AUTHORITY": "$PACKAGE_NAME"
,
"cordova-plugin-camera": ,
"cordova-plugin-file": ,
"cordova-plugin-file-transfer": ,
"cordova-plugin-filepath": ,
"info.protonet.imageresizer": ,
"cordova-plugin-network-information": ,
"cordova-plugin-googlemaps":
"API_KEY_FOR_ANDROID": "My_Key",
"API_KEY_FOR_IOS": "My_Key",
"LOCATION_WHEN_IN_USE_DESCRIPTION": "This app wants to get your location while this app runs only.",
"LOCATION_ALWAYS_USAGE_DESCRIPTION": "This app wants to get your location always, even this app runs in background."
我会很感激每一条线索,我真的迷路了。谢谢您的帮助!如果有不清楚的地方,请询问我会尝试更好地解释它。
编辑:我创建了一个最小的项目来重现问题https://github.com/NuritArmelle/Bug-googlemaps-not-installed
这是我复制的步骤(在 Mac 上):
npm install
npm rebuild node-sass --unsafe-perm
ionic cordova platform add ios
ionic cordova prepare ios
npm install @ionic-native/core@beta
npm install @ionic-native/google-maps@beta
ionic cordova plugin add cordova-plugin-googlemaps#multiple_maps --variable API_KEY_FOR_ANDROID="my android key" --variable API_KEY_FOR_IOS="my IOS key"
此时,当我尝试构建时,它已经给了我错误“GoogleMaps/GoogleMaps.h 未找到”。 (这次我在 xcworkspace)。
然后我在平台/ios 中创建了我的 Podfile(这是它的内容):
DO NOT MODIFY -- auto-generated by Apache Cordova
platform :ios, '8.0'
target 'Bug-Googlemaps-not-installed' do
project 'Bug-Googlemaps-not-installed.xcodeproj'
pod 'GoogleMaps', '~> 2.7.0'
end
最后,我做了一个“pod install”。还是同样的问题,无法建立“GoogleMaps.h”的原因。
【问题讨论】:
【参考方案1】:我以这种方式解决,请按照我所做的更改:
-
删除这些文件夹:platforms、node_modules、plugins、www e package-lock.json。
卸载科尔多瓦:
sudo npm uninstall -g cordova
安装科尔多瓦:sudo npm install -g cordova
从谷歌地图安装 SDK:ionic cordova plugin add https://github.com/mapsplugin/cordova-plugin-googlemaps-sdk.git
安装插件谷歌地图:ionic cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_IOS="your_api_key"
ionic cordova platform add ios.
ionic cordova prepare ios.
ionic cordova debug ios.
open xcode.
【讨论】:
以上是关于如何使用 Ionic 4 在 IOS 上修复“cordova-plugin-googlemaps 尚未安装或准备就绪”的主要内容,如果未能解决你的问题,请参考以下文章
Ionic 3. 如何使用 cli 定位特定版本的 iOS 模拟器?
如何从 Ionic 5 中的@ionic/angular 错误修复成员事件