[英]Native component for "AIRMap" does not exist
react-native: 0.53.3
react-native-maps@0.20.1
I'm trying to use react-native-maps and I keep getting this error.我正在尝试使用react-native-maps并且不断收到此错误。 This is in a fresh project:
这是在一个新项目中:
react-native init maps
cd maps/
npm install --save react-native-maps
react-native run-ios
And in App.js
I've added this:在
App.js
我添加了这个:
...
import MapView from 'react-native-maps';
export default class App extends Component<Props> {
render() {
return (
<View>
<MapView
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
</View>
);
}
}
This seems to be the bare minimum to get this running, but my iOS simulator is complaining about "AIRMap".这似乎是让它运行的最低要求,但我的 iOS 模拟器抱怨“AIRMap”。
In my case I had the same result after following the instructions and the solution at the end was really simple.就我而言,按照说明进行操作后得到了相同的结果,最后的解决方案非常简单。
I went to Xcode -> Clean -> Build.我去了 Xcode -> Clean -> Build。
There I saw that I had 2 errors in my code:
在那里,我看到我的代码中有 2 个错误:
Expected ';'预期的 ';' after module name (@import GoogleMaps)
在模块名称之后(@import GoogleMaps)
Use of undeclared identifier ([GMSPlacesClient provideAPIKey:@"MY_KEY"];)使用未声明的标识符 ([GMSPlacesClient provideAPIKey:@"MY_KEY"];)
So, I added ';'所以,我加了';' and deleted the line GMSPlacesClient provideAPIKey:@"MY_KEY"];
并删除了行 GMSPlacesClient provideAPIKey:@"MY_KEY"];
After that I executed again 'npm run ios' and all worked like a charm!之后我再次执行'npm run ios' ,一切都像魅力一样!
There are other solutions here:这里还有其他解决方案:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.