安装React Native Map在UIManager中找不到AIRMap

时间:2018-09-17 20:57:20

标签: javascript reactjs react-native react-native-maps

可能有人在问这个问题,我一直在Github上找,但是找不到适合安装React Native Maps的解决方案...

  

不变违规:requireNativeComponent:在以下位置找不到“ AIRMap”   UIManager。

     

此错误位于:       在AIRMap中(位于MapView.js:760)       在MapView中(位于Home.js:118)

  "react-native": "^0.57.0-rc.4",
  "react-native-maps": "^0.21.0",

我尝试过:

rm -rf ios android node_modules
npm install
react-native upgrade
react-native link

libAirMaps.a is added in Build Phases
AirGoogleMaps and AirMaps is added to Libraries

按照本指南的操作,无需添加CocoaPods,即可手动添加iOS版Maps SDK:https://developers.google.com/maps/documentation/ios-sdk/start

@import GoogleMaps;[GMSServices provideAPIKey:@"_YOUR_API_KEY_"];添加到AppDelegate.m

仍然出现相同的错误...

我还没有将其添加到package.json中,因为我不确定它要求的路径是什么?我在https://github.com/react-community/react-native-maps/blob/master/docs/installation.md

找到了
{
  "name": "your-app",
  "scripts": {
    "postinstall": "./node_modules/react-native-maps/enable-google-maps REPLACE_ME_RELATIVE_PATH_TO_GOOGLE_MAPS_INSTALL"
  }
}

2 个答案:

答案 0 :(得分:3)

如果您遵循Google Map文档并手动安装SDK,则可能已将这三个框架添加到了项目中,只需右键单击Xco​​de中的框架,然后在Finder中显示,即可找到Finder中的框架文件

enter image description here

enter image description here

在我的情况下,REPLACE_ME_RELATIVE_PATH_TO_GOOGLE_MAPS_INSTALL指向我的ios目录,相关路径为./ios,只需将其添加到package.json文件中并运行     npm install

{
  "name": "your-app",
  "scripts": {
     "postinstall": "./node_modules/react-native-maps/enable-google-maps ./ios"
  }
}

答案 1 :(得分:0)

另一个答案可能与RN> 0.60不再相关。请确保按照此处的安装说明进行操作:https://github.com/react-native-community/react-native-maps/blob/master/docs/installation.md,其中包括appdelegate.m的更改和podfile的更改。然后,将以下行添加到podfile的顶部。

来源'https://github.com/CocoaPods/Specs.git'