Google 登录无法在 iOS 10 Beta 7 和 Xcode 8 beta 6 上运行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39091841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:10:14  来源:igfitidea点击:

Google Sign In not working on iOS 10 Beta 7 with Xcode 8 beta 6

iosobjective-cxcodegoogle-signinios10

提问by Pranoy C

I have an app in the app store which worked perfectly fine till first few betas of iOS 10 (i am not exactly sure which one). It also works perfectly fine on iOS 9.3.

我在应用程序商店中有一个应用程序,它运行良好,直到 iOS 10 的前几个测试版(我不确定是哪一个)。它在 iOS 9.3 上也能完美运行。

However I am not testing on iOS 10 beta 7 and the google sign in is completely broken. I am using the latest version of GIDSignInfrom cocoapods.

但是我不是在 iOS 10 beta 7 上测试,谷歌登录完全坏了。我正在使用最新版本的GIDSignInfrom cocoapods

Here's my code:

这是我的代码:

[GIDSignIn sharedInstance].clientID = [[ParseFetcher sharedInstance] getRandomParseK];
[GIDSignIn sharedInstance].delegate = sharedInstance;
[GIDSignIn sharedInstance].uiDelegate=sharedInstance;
[GIDSignIn sharedInstance].scopes = [NSArray arrayWithObjects:@"https://www.googleapis.com/auth/youtube",@"https://www.googleapis.com/auth/youtube.force-ssl", nil];
[[GIDSignIn sharedInstance] signIn];

This is how it looks like on device:

这是它在设备上的样子:

screenshot 1

截图 1

It just stays stuck like this.

它只是像这样卡住。

If I click the refresh button at top, it tries to refresh and gets stuck here forever.

如果我单击顶部的刷新按钮,它会尝试刷新并永远卡在此处。

screenshot 2

截图 2

Clicking on the done button sends me back to my app.

单击完成按钮将我返回到我的应用程序。

There are no errors logged in the console.

控制台中没有记录错误。

However, when I run the same app on iOS 10 simulator, the safari view controllerdoesn't even open. Nothing happens at all. But the console logs this long verbose stuff out of which the following seems like the most "useful" stuff but I have no clue what's wrong:

但是,当我在 iOS 10 模拟器上运行相同的应用程序时,safari view controller它甚至没有打开。什么都没有发生。但是控制台记录了这些冗长冗长的内容,其中以下内容似乎是最“有用”的内容,但我不知道出了什么问题:

nw_endpoint_resolver_receive_report [8 i.ytimg.com:443 in_progress resolver (satisfied)] received child report:[8.1 206.248.149.148:443 waiting path (satisfied)]
2016-08-22 23:19:51.531570 XXXXAPPNAMEXXXXXXX[4561:195631] [] nw_connection_endpoint_report [8.1 206.248.149.148:443 waiting path (satisfied)] reported event path:satisfied
2016-08-22 23:19:51.531909 XXXXAPPNAMEXXXXXXX[4561:195631] [] nw_endpoint_proxy_handler_should_use_proxy Looking up proxy for hostname: <nil>, ifindex: 0
2016-08-22 23:19:51.533116 XXXXAPPNAMEXXXXXXX[4561:195631] [] -[NWConcrete_nw_endpoint_flow startWithHandler:] [8.1 206.248.149.148:443 waiting socket-flow (satisfied)]
2016-08-22 23:19:51.533548 XXXXAPPNAMEXXXXXXX[4561:195631] [] nw_endpoint_flow_setup_socket [8.1 206.248.149.148:443 in_progress socket-flow (satisfied)] creating socket
2016-08-22 23:19:51.534108 XXXXAPPNAMEXXXXXXX[4561:195631] [] nw_endpoint_flow_attach_protocols [8.1 206.248.149.148:443 in_progress socket-flow (satisfied)]
2016-08-22 23:19:51.534672 XXXXAPPNAMEXXXXXXX[4561:195631] [] __nwlog_err_simulate_crash simulate crash already simulated "nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available"
2016-08-22 23:19:51.535415 XXXXAPPNAMEXXXXXXX[4561:195631] [] nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available, dumping backtrace:
        [x86_64] libnetcore-856.1.8
    0   libsystem_network.dylib             0x000000010c6e280e __nw_create_backtrace_string + 123
    1   libnetwork.dylib                    0x000000010e0d5194 nw_socket_add_input_handler + 3002
    2   libnetwork.dylib                    0x000000010e0b2db8 nw_endpoint_flow_attach_protocols + 3768
    3   libnetwork.dylib                    0x000000010e0b1dd5 nw_endpoint_flow_setup_socket + 563
    4   libnetwork.dylib                    0x000000010e0b0b34 -[NWConcrete_nw_endpoint_flow startWithHandler:] + 2612
    5   libnetwork.dylib                    0x000000010e0cbd11 nw_endpoint_handler_path_change + 1261
    6   libnetwork.dylib                    0x000000010e0cb740 nw_endpoint_handler_start + 570
    7   libnetwork.dylib                    0x000000010e0e3003 nw_endpoint_resolver_start_next_child + 2240
    8   libdispatch.dylib                   0x000000
2016-08-22 23:19:51.535995 XXXXAPPNAMEXXXXXXX[4561:195631] [] nw_endpoint_flow_attach_protocols [8.1 206.248.149.148:443 in_progress socket-flow (satisfied)] Attached flow protocol
2016-08-22 23:19:51.536475 XXXXAPPNAMEXXXXXXX[4561:195631] [] nw_endpoint_resolver_receive_report [8 i.ytimg.com:443 in_progress resolver (satisfied)] received child report:[8.1 206.248.149.148:443 in_progress socket-flow (satisfied)]

NOTE: iOS 9.3 works perfectly. Also happens on all devices - tested on iPhone 6s and iPhone 5s.

注意:iOS 9.3 完美运行。也发生在所有设备上 - 在 iPhone 6s 和 iPhone 5s 上测试。

采纳答案by Pranoy C

I am not sure if this is what other people are facing but I solved it by adding a [self.view layoutIfNeeded]. I know this is weird but this is what worked for me, I am myself not sure why.

我不确定这是否是其他人面临的问题,但我通过添加[self.view layoutIfNeeded]. 我知道这很奇怪,但这对我有用,我自己也不知道为什么。

I was using a custom view container inside which I was showing the Google's sign in view controller as a child. So before adding the custom view controller to the container, i had to do [self.view layoutIfNeeded]as else the view layout hadn't been set yet, so google's sdk probably uses the width/height somewhere inside.

我正在使用一个自定义视图容器,我在其中显示了作为孩子的 Google 登录视图控制器。因此,在将自定义视图控制器添加到容器之前,我必须执行[self.view layoutIfNeeded]其他操作,否则视图布局尚未设置,因此 google 的 sdk 可能使用内部某处的宽度/高度。

I am not sure if this is the right solution but it seems to have fixed my issue.

我不确定这是否是正确的解决方案,但它似乎解决了我的问题。

回答by Basheer

Google SignIn sample iOS project too has the same issue.

Google SignIn 示例 iOS 项目也有同样的问题。

It returns:

它返回:

"Error Domain=com.google.GIDSignIn Code=-2 "keychain error" UserInfo={NSLocalizedDescription=keychain error}"

This seems to be a bug.

这似乎是一个错误。

回答by Amir Aharon

I'm (still) using Google+ SDK for sign-in (1.7.1), and it also brokenon iOS 10 beta 7. I was thinking about moving to GIDSignIn since GPPSignIn is deprecated. but I guess I will wait for next beta...

我(仍在)使用 Google+ SDK 进行登录 (1.7.1),并且它在 iOS 10 beta 7 上也被破坏了。由于 GPPSignIn 已被弃用,我正在考虑迁移到 GIDSignIn。但我想我会等待下一个测试版......

回答by Dylan Diamond

Turn on "Keychain Sharing" in the capabilities tab of your target and it will work.

在目标的功能选项卡中打开“钥匙串共享”,它将起作用。

回答by jqwang

I am able to find a solution in my case by fixing my code to present a subview properly. Before I was getting this warning but ignored it:

通过修复我的代码以正确呈现子视图,我能够找到适合我的解决方案。在我收到此警告但忽略它之前:

Warning :-Presenting view controllers on detached view controllers is discouraged

until I saw Pranoy C's answer. My code is structured in a very similar way that a view container is used to present subviews which contain the Google button. It was not using the container correctly to present a subview. So I followed Apple's guide, especially this block:

直到我看到 Pranoy C 的回答。我的代码以非常相似的方式构建,即使用视图容器来呈现包含 Google 按钮的子视图。它没有正确使用容器来呈现子视图。所以我遵循了Apple 的指南,尤其是这个块:

- (void) displayContentController: (UIViewController*) content {
    [self addChildViewController:content];
    content.view.frame = [self frameForContentController];
    [self.view addSubview:self.currentClientView];
    [content didMoveToParentViewController:self];
}

Once the warning was gone, Google started to work properly.

警告消失后,Google 开始正常工作。

As far as root cause of this issue, I'm still not exactly sure, but the warning seems to be a hint. It has to do with detached view controllers. (I'm not super experienced at iOS coding, so if someone has more knowledge with views, view controllers, feel free to chime in.)

至于这个问题的根本原因,我仍然不确定,但警告似乎是一个提示。它与分离的视图控制器有关。(我在 iOS 编码方面不是很有经验,所以如果有人对视图、视图控制器有更多的了解,请随时加入。)

回答by Roy Kolak

Our issue was some third party plugins trying to auto integrate into our app delegate. For us, it was CleverTap (the autoIntegrate()function).

我们的问题是一些第三方插件试图自动集成到我们的应用程序委托中。对我们来说,它是 CleverTap(autoIntegrate()函数)。

回答by MRizwan33

Do Nothing Just set the clientID while application is being finished launching. Like Given in the code below:

什么都不做 只需在应用程序完成启动时设置 clientID。就像在下面的代码中给出的一样:

import FBSDKLoginKit import GoogleSignIn import GGLCore

导入 FBSDKLoginKit 导入 GoogleSignIn 导入 GGLCore

@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {

@UIApplicationMain 类 AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {


    var ConfigError : NSError?
    GGLContext.sharedInstance().configureWithError(&ConfigError)
    assert(ConfigError == nil, "Error Configuration with Google services: \(ConfigError)")
    GIDSignIn.sharedInstance().clientID = "679401366566-8107g2n11hpnqas58m9v8rk7hl2lgl7s.apps.googleusercontent.com" // Here You Have To Change Your App ID

    let fbDelegate = FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    print("DidFinish")

    return fbDelegate
}