未找到React Native ios'GoogleMaps / GoogleMaps.h'文件

时间:2018-06-13 12:22:14

标签: react-native react-native-maps

我的应用程序出了问题。

当我尝试在 Android Studio 上构建它时,一切正常但当我尝试在 Xcode 上构建它时,我收到错误并且构建失败。

原因似乎来自AirMaps:

词法或预处理器问题

找不到

'GoogleMaps/GoogleMaps.h'个文件

AIRGoogleMapUrlTile.h

这很奇怪,因为它到目前为止工作正常,我找不到原因。

我正在使用:

- "react": "16.0.0-alpha.6",
- "react-native": "0.43.3",
- "react-native-maps": "^0.21.0"

这是我的Podfile:

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '9.0'

target 'Situaction' do
  rn_path = '../node_modules/react-native'
  rn_maps_path = '../node_modules/react-native-maps'

  pod 'Fabric'
  pod 'Crashlytics'

  pod 'GoogleMaps'
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

请你帮帮我吧,

提前致谢

编辑:
这是标题搜索路径。 Header Search Paths

5 个答案:

答案 0 :(得分:3)

如果您使用的是React Native 0.60和更高版本,请将以下内容添加到Podfile函数上方的use_native_modules!并在ios文件夹中运行pod install

  # React Native Maps dependencies
  rn_maps_path = '../node_modules/react-native-maps'
  pod 'react-native-google-maps', :path => rn_maps_path
  pod 'GoogleMaps'
  pod 'Google-Maps-iOS-Utils'

visit the documentation

答案 1 :(得分:1)

好的,所以我找到了一个可行的解决方案:

  

在podfile中添加pod Google-Maps-iOS-Utils
  从库中删除AirMaps.xcodeproj
  从Link Binary with Libraries中删除libAirMap.a

但是现在我遇到了一个新问题:地图出现了,但是现在我不能使用fitToCoordinates了,因为发生了错误:

Unknown argument type 'AIRMapCoordinatesArray' in method - [AIRGoogleMapManager fitToCoordinates:coordinates:edgePadding:animated: ). Extend RCTConvert to support this type.

当我看一下调试器时,它会告诉我:

Warning: Native component for "AIRMap" does not exist

(我报告的react-native-maps issue中的更多信息)

编辑:
我在项目中添加了AirMaps文件夹,一切似乎都正常运行

答案 2 :(得分:0)

以下链接帮助我解决了同样的问题。 https://gist.github.com/heron2014/e60fa003e9b117ce80d56bb1d5bfe9e0

答案 3 :(得分:0)

target 'YourApp' do
  rn_path = '../node_modules/react-native'
  rn_maps_path = '../node_modules/react-native-maps'

  pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
  pod 'React', path: rn_path, subspecs: [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'BatchedBridge'
  ]

  pod 'react-native-maps', path: rn_maps_path

  pod 'GoogleMaps'  # Remove this line if you don't want to support Google Maps on iOS
  pod 'react-native-google-maps', path: rn_maps_path  # Remove this line if you don't want to support Google Maps 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

答案 4 :(得分:0)

就我而言,我将AirMaps的框架搜索路径更新为$(PROJECT_DIR) (recursive),而$(inherited) (recursive)对我有用。

enter image description here

enter image description here

我不确定它是否适合您。请给我反馈。