Ionic 3 - 更新后无法构建Google地图

时间:2017-06-06 12:11:11

标签: ios cordova google-maps ionic-framework

我已经被Ionic的Google Maps插件困住了一段时间。到目前为止,它在Android和iOS上运行得非常好,但自从我将我的应用程序表单Ionic 2更新为3后,我无法为iOS构建它。

我已经尝试删除所有npm模块和所有插件和平台并重新安装它们,我一直在寻找和谷歌搜索解决方案几个小时,我开始绝望了。在android中我构建或运行应用程序没有问题。

我正在使用xcode构建应用程序(打开工作区的文件,而不是项目的文件),但总有两个相关的错误:

  

/.../ platforms / ios / appname / Plugins / com.googlemaps.ios / GoogleMaps.framework / Headers / GMSPolyline.h:11:9:找不到'UIKit / UIKIt.h'文件

导致下一个错误:

  

/.../ platforms / ios / appname / Plugins / cordova-plugin-googlemaps / GoogleMaps.h:10:9:无法构建模块'GoogleMaps'

这是config.xml中的maps plugin标签:

<plugin name="cordova-plugin-googlemaps" spec="~1.4.0">
    <variable name="API_KEY_FOR_ANDROID" value="myapikeyforandroid" />
    <variable name="API_KEY_FOR_IOS" value="myapikeyforios" />
    <variable name="NSLOCATIONWHENINUSEUSAGEDESCRIPTION" value="Show your location on the map" />
    <variable name="NSLOCATIONALWAYSUSAGEDESCRIPTION" value="Trace your location on the map" />
</plugin>

在package.json中我有这些依赖:

"dependencies": {
    "@angular/common": "4.1.2",
    "@angular/compiler": "4.1.2",
    "@angular/compiler-cli": "4.1.2",
    "@angular/core": "4.1.2",
    "@angular/forms": "4.1.2",
    "@angular/http": "4.1.2",
    "@angular/platform-browser": "4.1.2",
    "@angular/platform-browser-dynamic": "4.1.2",
    "@ionic-native/background-geolocation": "^3.12.1",
    "@ionic-native/background-mode": "^3.12.1",
    "@ionic-native/barcode-scanner": "^3.12.1",
    "@ionic-native/core": "3.11.0",
    "@ionic-native/geolocation": "^3.12.1",
    "@ionic-native/google-maps": "^3.12.1",
    "@ionic-native/local-notifications": "^3.12.1",
    "@ionic-native/push": "^3.12.1",
    "@ionic-native/secure-storage": "^3.12.1",
    "@ionic-native/social-sharing": "^3.12.1",
    "@ionic-native/splash-screen": "^3.12.1",
    "@ionic-native/status-bar": "^3.11.0",
    "@ionic-native/streaming-media": "^3.12.1",
    "@ionic-native/video-player": "^3.12.1",
    "@ionic/storage": "2.0.1",
    "angular2-jwt": "^0.2.3",
    "ionic-angular": "3.3.0",
    "ionicons": "3.0.0",
    "rxjs": "5.1.1",
    "socket.io-client": "^1.7.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.11"
  }

如果我能提供更多线索,请告诉我......

提前感谢您的帮助。

编辑:我尝试添加UIKit库并重新安装XCode,但没有任何效果。如果我删除谷歌地图插件,该应用程序构建正常,所以它似乎与cordova-plugin-googlemaps有关我现在正在尝试其他版本以确定这是否是版本问题。

编辑2:更改谷歌地图版本没有任何影响...

编辑3:我找到了this thread,看起来与此类似,但也没有任何答案。

3 个答案:

答案 0 :(得分:0)

听起来您的错误可能类似于this answer中提到的错误。

试试并报告回来!

答案 1 :(得分:0)

好吧,在尝试了所有可以解决的解决方案之后,我得出了最简单的结论:UIKit.h导入并不需要。所以我刚刚从目录platform / ios / AppName / Plugins / com.googlemaps.ios / GoogleMaps.framework / Headers中的文件GMSTileLayer.h和GMSPolyline.h中删除了行#import <UIKit/UIKIt.h>,现在它工作得很好。我想知道为什么在版本更改之前没有给出任何错误,因为googlemaps插件版本始终是相同的。

答案 2 :(得分:0)

我遇到了同样的问题,但是找到了解决方案。问题是原始文件中有错字。

#import <UIKit/UIKIt.h> 应该 #import <UIKit/UIKit.h>(UIKit.h中的第二个i现在是小写字母)

我在GMUGradient.h文件中修复了此错误之后,在Xcode给我错误的地方,构建顺利进行。