1

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

我的 package.json 片段:

"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 的解决方案,但我很好奇是否有人通过解决此错误手动完成了它。我不确定我做错了什么。

4

1 回答 1

2

最后在这里找到了我所缺少的:适用于 iOS 的 Google Maps SDK 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 的步骤,在 google 文档的第 4 步中

    将以下包拖到 Xcode 中的 Frameworks 下的项目中(出现提示时,如果需要,请选择 Copy items):

    • 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,然后选择 Show In Finder。它没有说的是......然后进入名为Resources的子文件夹

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

    • GoogleMapsBase.framework
    • 谷歌地图框架
    • GoogleMapsCore.framework
    • libAirMaps.a 注意:如果 libAirMaps.a 没有自动链接,您可以通过将 AirMaps.xcodeproj 从 node_modules/react-native-maps/lib/ios 拖动到 k/start 上的 Libraries 文件夹来手动链接

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

于 2019-01-21T15:14:09.203 回答