【问题标题】:AirGoogleMaps dir must be added to your xCode project to support GoogleMaps on iOS React Native必须将 AirGoogleMaps 目录添加到您的 xCode 项目以支持 iOS React Native 上的 GoogleMaps
【发布时间】:2019-01-21 13:31:43
【问题描述】:

我正面临这个问题,我相信很多其他人在经过一番搜索后都会面临这个问题。我正在尝试手动安装 Google maps IOS SDK 而不是 pods 方法。任何与 pod 有关的解决方案都不适合我。我能够渲染地图,但是当我提供“provider google”时,它会抛出错误。我需要谷歌地图而不是苹果地图。 到目前为止我做了什么:

我的 package.json sn-p:

"scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"   
 },   
 "dependencies": {
    "moment": "^2.22.2",
    "npm": "^6.5.0",
    "react": "16.6.3",
    "react-native": "0.57.8",
    "react-native-blur": "^3.2.2",
    "react-native-drawer": "^2.5.0",
    "react-native-elements": "^0.19.1",
    "react-native-maps": "^0.23.0",

我正在关注这个文档,除了一些小的调整之外,我认为它非常准确。

我的渲染地图的本机组件。

import React from 'react'
import { ScrollView, View } from 'react-native'
import styles from './style'
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps'

class Location extends React.Component {

  render () {
    return (
      <View style={styles.container}>
        <MapView
          provider={PROVIDER_GOOGLE} // remove if not using Google Maps
          style={styles.map}
          region={{
            latitude: 37.78825,
            longitude: -122.4324,
            latitudeDelta: 0.015,
            longitudeDelta: 0.0121,
          }}
        >
        </MapView>
      </View>
    )
  }
}

我的 Xcode 文件层次结构:

链接的库:

另外,我在构建设置中包含了标题搜索中的路径。此外,我在 Xcode 中的库下包含了 AirMaps.xcodeproj。我已经看到了更多使用 Podfile 的解决方案,但我很好奇是否有人通过解决此错误手动完成了它。我不确定我做错了什么。

【问题讨论】:

    标签: ios react-native google-maps-sdk-ios google-maps-react


    【解决方案1】:

    终于在这里找到了我所缺少的:Google Maps SDK for iOS requires GoogleMaps.bundle to be part of your target under 'Copy Bundle Resources

    所以我所做的是安装 react-native 的步骤:

    1. npm install --save react-native-maps
    2. react-native link react-native-maps
    3. 从这里下载 google maps ios SDK [https://developers.google.com/maps/documentation/ios-sdk/start
    4. 按照手动安装ios SDK的步骤,在第4 谷歌文档步骤

      将以下包拖到您的项目中的框架下 Xcode(出现提示时,如果需要,选择复制项目):

      • GoogleMaps-2.7.0/Base/Frameworks/GoogleMapsBase.framework

      • GoogleMaps-2.7.0/Maps/Frameworks/GoogleMaps.framework

      • GoogleMaps-2.7.0/Maps/Frameworks/GoogleMapsCore.framework

    5. 在您的项目中右键单击 GoogleMaps.framework,然后选择显示在 发现者。它没有说的是......然后进入子文件夹 称为资源

    6. 将 GoogleMaps.bundle 从 Resources 文件夹拖到您的 项目。我们建议将其放在 Frameworks 文件夹下 Xcode。 出现提示时,确保将项目复制到目标组的 未选择文件夹。
    7. 在 Xcode 中为您的项目转到 Build Settings 并键入“Header Search Paths”在搜索栏中双击调试查看 调试版本中的标头搜索路径。单击 + 添加路径和 使用递归选项添加“$(SRCROOT)/Frameworks/”。
    8. 在 Xcode 中转到项目的构建阶段。添加以下内容 框架和库。

      • GoogleMapsBase.framework
      • GoogleMaps.framework
      • GoogleMapsCore.framework
      • libAirMaps.a 注意: 如果 libAirMaps.a 没有自动链接,您可以通过拖动 AirMaps.xcodeproj 手动链接 node_modules/react-native-maps/lib/ios 到 Libraries 文件夹 k/开始

    希望它可以帮助任何人:)

    【讨论】:

    猜你喜欢
    • 2019-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多