我按照说明安装了react-native-google-places但是当我尝试运行应用程序时出现此错误:
以下是我采取的步骤:
1) react-native init awesomeApp && cd awesomeApp
2) yarn add react-native-google-places
3) react-native link react-native-google-places
4)在/ ios文件夹中,我使用此内容创建podfile
source 'https://github.com/CocoaPods/Specs.git'
target 'awesomeApp' do
pod 'GooglePlaces'
pod 'GoogleMaps'
pod 'GooglePlacePicker'
end
5)我用google创建了一个API密钥(我现在暂时分享这个密钥,但稍后会禁用它: AIzaSyA5u8ez8uuyGvAa98XzH7rY1MCnHrED-rw
)
6)我将AppDelegate.m文件更新为如下所示:
@import GooglePlaces;
@import GoogleMaps;
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
[GMSPlacesClient provideAPIKey:@"AIzaSyDEmY7AqrJbrr1oD4Pe82H_xAHt3C0xafM"];
[GMSServices provideAPIKey:@"AIzaSyDEmY7AqrJbrr1oD4Pe82H_xAHt3C0xafM"];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"awesomeApp"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
@end
7)我从/ ios运行 pod install
8)然后 react-native run-ios
从root
9)我在index.ios.js中包含 import RNGooglePlaces from 'react-native-google-places';
10)然后在 return
之前的渲染函数中添加 RNGooglePlaces.openAutocompleteModal();
据我所知,这些步骤应该产生一个带有谷歌地方自动完成功能的模态 . 有人可以指出它为什么没有?