【问题标题】:console.error: "react-native-maps" AirGoogleMaps dir must be added to your xCode projectconsole.error: "react-native-maps" AirGoogleMaps 目录必须添加到您的 xCode 项目中
【发布时间】:2016-12-21 15:30:19
【问题描述】:

console.error: "react-native-maps" AirGoogleMaps 目录必须添加到您的 xCode 项目中

我在尝试测试 react-native-maps 模块中的示例时遇到此错误。

Github:https://github.com/airbnb/react-native-maps/tree/master/example

很明显,我应该将目录添加到我的 Xcode 项目中,但我不知道如何添加它们。

我可以举一个将目录添加到 Xcode 项目的示例吗?

【问题讨论】:

  • 我已经尝试了这三个选项。对于第一个选项:我不知道如何将目录添加到 Xcode 项目。对于第二个选项:我想我完全遵循了对于第三个选项:我找不到 libAIRMaps.a 文件
  • 文档真的很糟糕。也许这个帖子会有所帮助:github.com/airbnb/react-native-maps/issues/693
  • 嘿,我面临同样的错误。不走运.. @ykn121 你能建造吗?
  • @ykn121 哦。我想在 iOS 上使用 GoogleMaps,所以需要手动安装包。

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


【解决方案1】:

我在使用 react native 0.61 时遇到了这个问题,我的解决方案是: 停止 Metro Bundler,然后进入 pods 目录:

cd ..
cd ios

再次安装 pod:

pod install

转到项目根目录:

cd ..

然后再次运行项目npx react-native run-ios

这是我的 Podfile 的片段

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

【讨论】:

    【解决方案2】:

    最近我遇到了这个问题,我的问题通过对 pod 文件的一些更改解决了。

    source 'https://github.com/CocoaPods/Specs.git'
    # Uncomment the next line to define a global platform for your project
    platform :ios, '9.0'
    
    target 'AppName' do
        pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
        pod 'React', :path => '../node_modules/react-native', :subspecs => [
        'Core',
        'RCTText',
        'RCTImage',
        'RCTAnimation',
        'RCTActionSheet',
        'RCTLinkingIOS',
        'RCTSettings',
        'RCTVibration',
        'RCTNetwork',
        'RCTWebSocket',
        'DevSupport',
        'BatchedBridge',
        'RCTGeolocation',
        ]
    
        pod 'GoogleMaps'  # Remove this line if you don't want to support GoogleMaps on iOS
        pod 'react-native-maps', path: '../node_modules/react-native-maps'
        pod 'react-native-google-maps', path: '../node_modules/react-native-maps'  # 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
    
            if target.name == "React"
                target.remove_from_project
            end
        end
    end
    

    同样在你的 JS 文件中你的 map 标签必须是这样的

    <MapView
        provider={PROVIDER_GOOGLE}                   
        style={styles.map}
        // provider='google'
        // mapType='standard'
        ...
    >
    

    请注意,您的 pod 文件必须正确链接。不需要手动添加任何东西。 您可以使用此命令删除您的 pod 文件和路径

    pod deintegrate
    

    pod clean
    

    以及安装 Cocoapods-Deintegrate Plugin 和 Cocoapods-Clean Plugin

    在您的终端上使用以下命令进行安装。

    sudo gem install cocoapods-deintegrate
    

    Cocoapods-清洁插件

    在您的终端上使用以下命令进行安装。

    sudo gem install cocoapods-clean
    

    希望对您有所帮助。

    【讨论】:

      【解决方案3】:

      我刚刚删除了MapView 组件中的以下道具,它起作用了!

      provider={MapView.PROVIDER_GOOGLE}

      【讨论】:

        猜你喜欢
        • 2019-04-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多