【问题标题】:Ionic 3 - Cannot build Google Maps after updateIonic 3 - 更新后无法构建谷歌地图
【发布时间】:2017-11-07 10:48:50
【问题描述】:

我已经被 Ionic 的谷歌地图插件卡住了一段时间了。到目前为止,它在 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 中的地图插件标签:

<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,看起来和这个类似,但也没有任何答案。

【问题讨论】:

    标签: ios cordova google-maps ionic-framework


    【解决方案1】:

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

    #import &lt;UIKit/UIKIt.h&gt; 应该是 #import &lt;UIKit/UIKit.h&gt;(UIKit.h 中的第二个 i 现在是小写)

    我在 GMUGradient.h 文件中修复了这个问题后,Xcode 给我错误的地方,构建运行顺利。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

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

        试一试,然后报告!

        【讨论】:

        • 谢谢!我已经尝试添加库,但是当我进入构建阶段时,它已经被添加了。框架搜索路径也很好,我从不更改任何配置。我现在将尝试按照该答案中的建议重新安装 XCode。
        • 我已经重新安装了XCode,再次删除并添加了ios平台并在再次编译之前点击了产品>清理,但问题仍然存在D:
        猜你喜欢
        • 2018-08-14
        • 2019-09-14
        • 2016-09-18
        • 1970-01-01
        • 2022-10-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多