安装React Native Map时出现问题。UIManager中未找到AIRMap。

9

可能有一些人正在问这个问题,我在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

按照此指南手动添加 Maps SDK for iOS,无需使用 CocoaPods:https://developers.google.com/maps/documentation/ios-sdk/start

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

仍然遇到相同的错误...

我没有将其添加到 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个回答

3
如果你按照Google Map文档并手动安装SDK,你可能需要将这三个框架添加到你的项目中,只需在Xcode中右键单击框架,然后选择“在Finder中显示”,就可以在Finder中找到框架文件。

enter image description here

enter image description here

and in my case , the REPLACE_ME_RELATIVE_PATH_TO_GOOGLE_MAPS_INSTALL refers to my ios directory, the related path is ./ios, just add this to the package.json file and run npm install

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


1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接