console.error: "react-native-maps" AirGoogleMaps 目录必须添加到您的 xCode 项目中
当我尝试在react-native-maps模块中测试示例时出现此错误。
Github:https ://github.com/airbnb/react-native-maps/tree/master/example
很明显,我应该将目录添加到我的 Xcode 项目中,但我不知道如何添加它们。
我可以举一个将 dir 添加到 Xcode 项目的示例吗?
console.error: "react-native-maps" AirGoogleMaps 目录必须添加到您的 xCode 项目中
当我尝试在react-native-maps模块中测试示例时出现此错误。
Github:https ://github.com/airbnb/react-native-maps/tree/master/example
很明显,我应该将目录添加到我的 Xcode 项目中,但我不知道如何添加它们。
我可以举一个将 dir 添加到 Xcode 项目的示例吗?
我在使用 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'
最近我遇到了这个问题,我的问题通过对 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
希望这可以帮助你。
我刚刚删除了MapView组件中的以下道具,它起作用了!
provider={MapView.PROVIDER_GOOGLE}