1

我正在使用 react-native-maps 并尝试使用适用于 iOS 的 Google 地图,我按照https://github.com/airbnb/react-native-maps/issues/693中的上述说明进行操作,因此我收到错误从 pod 安装:

找不到名为的目标AirMapsExplorer

这是我拥有的 podfile

# You Podfile should look similar to this file. React Native currently does not support use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'

# Change 'AirMapsExplorer' to match the target in your Xcode project.
target 'AirMapsExplorer' do

  pod 'Yoga', :path => '../../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
  pod 'React', path: '../../node_modules/react-native', :subspecs => [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'BatchedBridge'
  ]

  pod 'GoogleMaps'  # <~~ remove this line if you do not want to support GoogleMaps on iOS
  pod 'react-native-maps', path: '../../'
  pod 'react-native-google-maps', path: '../../'  # <~~ if you need GoogleMaps support 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
  end
end

我重新启动了我的设备(现在 2 次)删除了 pod 文件夹和 podfile,再次按照说明操作并得到相同的错误。我什至尝试过清理构建和清理文件夹仍然无济于事。

如果您遇到此错误,任何人都会遇到此错误或遇到解决方法。我不经常使用 xcode,因为我正在使用 React Native 进行构建,并且尽量不要使用 xcode 做太多事情,除非我绝对必须使用 iOS。

如果您希望我展示其他内容,我将帮助调试此问题。谢谢

4

1 回答 1

1

当你开始这个项目时,你需要在你的目标中输入xcodeprojXCode 创建的名称,你还需要检查你的文件.podFile是否在你的xcodeproj文件目录中,我认为你错过了这一行

workspace 'AirMapsExplorer'

这将创建一个集成了您的 pod 的工作区

您的 pod 文件已修改

# You Podfile should look similar to this file. React Native currently does not support use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'

workspace 'AirMapsExplorer'

# Change 'AirMapsExplorer' to match the target in your Xcode project.
target 'AirMapsExplorer' do

  pod 'Yoga', :path => '../../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
  pod 'React', path: '../../node_modules/react-native', :subspecs => [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'BatchedBridge'
  ]

  pod 'GoogleMaps'  # <~~ remove this line if you do not want to support GoogleMaps on iOS
  pod 'react-native-maps', path: '../../'
  pod 'react-native-google-maps', path: '../../'  # <~~ if you need GoogleMaps support 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
  end
end

希望这可以帮助

于 2017-08-07T18:47:46.790 回答