【问题标题】:How to fix"AIRMap" was not found in the UIManager error in react native?如何修复 react native 的 UIManager 错误中找不到“AIRMap”?
【发布时间】:2018-12-21 10:02:09
【问题描述】:

未处理的 JS 异常:不变违规:requireNativeComponent:在 UIManager 中找不到“AIRMap”。

此错误位于: 在 AIRMap 中(在 MapView.js:760) 在 MapView 中(在 App.js:25) 在 RCTView 中(在 View.js:43) 在应用程序中(在 renderApplication.js:32) 在 RCTView 中(在 View.js:43) 在 RCTView 中(在 View.js:43) 在 AppContainer 中(在 renderApplication.js:31)

如何在 react native ios 中修复这个错误?

【问题讨论】:

  • 你修好了吗? :( 我无法让它工作。你能分享一下你是如何解决它的吗?
  • 同样的错误,现在没有修复。
  • 从那以后您找到解决方案了吗? @ajnasaskar ?

标签: ios react-native react-native-maps


【解决方案1】:

添加到ios/YOUR_PROJECT_NAME/AppDelegate.m

@import GoogleMaps; //add this line if you want to use Google Maps

和

[GMSServices provideAPIKey:@"_YOUR_API_KEY_"]; // add this line using the api key obtained from Google Console

【讨论】:

  • 我已经尝试过了,但仍然是同样的错误。 @KateYeEum 你找到解决方案了吗?
【解决方案2】:

我也遇到了这个错误,我是这样修复的:

  1. 在您的项目中,转到 package.json
  2. 在依赖关系中反应原生地图应该是这样的:“react-native-maps”:“https://github.com/react-community/react-native-maps.git”
  3. 转到终端/cmd 并运行 npm-install
  4. 别忘了链接:“react-native link react-native-maps”

  5. 然后:react-native run-ios/android

因为只有一个人可以在 npm 上发布,所以我们应该使用 Git 来获取最新的更新等。

【讨论】:

    【解决方案3】:

    我已将以下脚本添加到 package.json。它对我有用。

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

    【讨论】:

      【解决方案4】:
      /*----------------Install----------------*/
      
      npm install react-native-maps --save
      
      /*----------------Get a Google Maps API key----------------*/
      
      /*----------------Write this in Pod file----------------*/
      
      # Uncomment the next line to define a global platform for your project
      # platform :ios, '9.0'
      
      target '_YOUR_PROJECT_TARGET_' do
          rn_path = '../node_modules/react-native'
          rn_maps_path = '../node_modules/react-native-maps'
      
      # See http://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies
          pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
      pod 'React', path: rn_path, subspecs: [
          'Core',
          'CxxBridge',
          'DevSupport',
          'RCTActionSheet',
          'RCTAnimation',
          'RCTGeolocation',
          'RCTImage',
          'RCTLinkingIOS',
          'RCTNetwork',
          'RCTSettings',
          'RCTText',
          'RCTVibration',
          'RCTWebSocket',
      ]
      
      # React Native third party dependencies podspecs
      pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
      pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
      # If you are using React Native <0.54, you will get the following error:
          # "The name of the given podspec `GLog` doesn't match the expected one `glog`"
      # Use the following line instead:
          #pod 'GLog', :podspec => "#{rn_path}/third-party-podspecs/GLog.podspec"
      pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"
      
      # react-native-maps dependencies
      pod 'react-native-maps', path: rn_maps_path
      pod 'react-native-google-maps', path: rn_maps_path  # Remove this line if you don't want to support GoogleMaps on iOS
      pod 'GoogleMaps'  # Remove this line if you don't want to support GoogleMaps on iOS
      pod 'Google-Maps-iOS-Utils' # Remove this line if you don't want to support GoogleMaps on iOS
      end
      
      post_install do |installer|
      installer.pods_project.targets.each do |target|
      if target.name == 'react-native-google-maps'
          target.build_configurations.each do |config|
      config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
      end
      if target.name == "React"
          target.remove_from_project
      end
      end
      end
      
      
      
      /*----------------Write this in AppDelegate .m----------------*/
      
      @import GoogleMaps
      
      In didFinishLaunchingWithOptions method
          [GMSServices provideAPIKey:@"_YOUR_API_KEY_"];
      
      /*----------------Now rut it with simulator or iOS device----------------*/
      
      /*----------------
      
      for more you can take reference of this :
      https://github.com/react-community/react-native-maps
      
      ----------------*/
      

      【讨论】:

      • 不错的复制粘贴。没有什么有用的,这里粘贴了相同的文档。
      • 我投了反对票,因为你没有解释就粘贴了代码。
      猜你喜欢
      • 2019-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-14
      • 2021-02-22
      • 1970-01-01
      • 2020-05-14
      相关资源
      最近更新 更多