簡體   English   中英

“AIRMap”的本機組件不存在

[英]Native component for "AIRMap" does not exist

react-native: 0.53.3
react-native-maps@0.20.1

我正在嘗試使用react-native-maps並且不斷收到此錯誤。 這是在一個新項目中:

react-native init maps
cd maps/
npm install --save react-native-maps
react-native run-ios

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>
    );
  }
}

這似乎是讓它運行的最低要求,但我的 iOS 模擬器抱怨“AIRMap”。

在此處輸入圖片說明

就我而言,按照說明進行操作后得到了相同的結果,最后的解決方案非常簡單。

我去了 Xcode -> Clean -> Build。

在那里,我看到我的代碼中有 2 個錯誤:

  1. 預期的 ';' 在模塊名稱之后(@import GoogleMaps)

  2. 使用未聲明的標識符 ([GMSPlacesClient provideAPIKey:@"MY_KEY"];)

所以,我加了';' 並刪除了行 GMSPlacesClient provideAPIKey:@"MY_KEY"];

之后我再次執行'npm run ios' ,一切都像魅力一樣!

這里還有其他解決方案:

  1. https://github.com/react-community/react-native-maps/issues/1798

  2. https://github.com/react-community/react-native-maps/issues/2064

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM