尝试在我的应用程序中集成 Google 登录时找不到 "GoogleService-Info.plist"

Unable to find "GoogleService-Info.plist" while trying to integrate Google Sign-in in my app

我已关注:Integrating Google Sign-In into your iOS app

然而,当我执行该应用程序时,它在应用程序委托本身中停止了——甚至在我看到我的第一个视图控制器之前。

原因是因为我在"application didFinishLaunchingWithOptions withOptions”中写的这几行代码,分别是:

"NSError* configureError;
[[GGLContext sharedInstance] configureWithError: &configureError];
    NSAssert(!configureError, @"Error configuring Google services: %@", configureError);

 [GIDSignIn sharedInstance].delegate = self;"

在调试中,当它到达这段代码时,它说

"Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error configuring Google services: Error Domain=com.google.greenhouse Code=-200 "Unable to configure GGL." UserInfo=0x7ff9c2e1d000 {NSLocalizedRecoverySuggestion=Check formatting and location of GoogleService-Info.plist., NSLocalizedDescription=Unable to configure GGL., NSLocalizedFailureReason=Unable to parse supplied GoogleService-Info.plist. See log for details.}'".

我将 GoogleService-Info.plist 放入我的目录中,但它仍然无法正常工作。

  1. 您必须将 GoogleService-Info.plist 文件拖放到项目中的某个位置,例如 Shared Resources。成功添加文件后,还应确保将其包含在项目构建中:

  1. 仔细检查项目的 "Build Phases" 部分是否包含 GoogleService-Info.plist

  2. 仔细检查文件名。文件名 必须 完全 GoogleService-Info.plist 常见的拼写错误包括 GoogleServices-Info.plistGoogleService-info.plist - 区分大小写且仅准确命名即可。

我遇到了同样的问题。而且,实际上,当我在 cocoapods 文件中放置 "pod 'Google/SignIn'" 而不是 "pod Google" 时,我解决了这个问题。希望对你也有帮助。

如果您只想获得 GCM_SENDER_ID,请尝试以下解决方法:

NSError* configureError;
[[GGLContext sharedInstance] configureWithError:&configureError];
NSString * gcmSenderID = [GGLContext sharedInstance].gcmSenderID;
NSLog(@"%@", gcmSenderID);

当我更新 google pods 时,我遇到了这种情况。他们改变了配置 URL 方案的方式。最好的方法是重新配置 google 登录。

对我来说.. 我忘了添加下面的 pods。 (因为我之前有一些本地问题...所以我删除了所有)

pod 'FirebaseUI/Auth'

pod 'FirebaseUI/Google'
pod 'FirebaseUI/Facebook'
pod 'FirebaseUI/OAuth' # Used for Sign in with Apple, Twitter, etc
pod 'FirebaseUI/Phone'

https://firebase.google.com/docs/auth/ios/firebaseui