我按照说明安装了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)我使用谷歌创建了一个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
从根
9)我在index.ios.js中加入import RNGooglePlaces from 'react-native-google-places';
10)然后在RNGooglePlaces.openAutocompleteModal();
return
据我所知,这些步骤应该会产生一个带有Google地方自动填充功能的模式。有人可以指出它为什么没有?