xcode 当我单击 Google 登录按钮时,iOS 应用程序崩溃

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31710011/
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 07:34:54  来源:igfitidea点击:

iOS app crashes when I click Google Sign-In button

iosxcodeswiftgoogle-signin

提问by user3798820

I'm using the Google Sign-In library for iOS, and when I click the Sign-In button the app crashes with the following error:

我正在使用适用于 iOS 的 Google 登录库,当我单击“登录”按钮时,应用程序崩溃并显示以下错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
 'Your app must support the following URL schemes: <my bundleID>,
 com.googleusercontent.apps.<my client ID>'

I inspected the signed version of my app to make sure that those URL schemes are defined, which they are.
I also added 'google' as the identifier for each of the URL schemes because I saw that that's what is done in the sample Google Sign-In app.

This only happens when I build the signed version of my app and do an ad-hoc installation on my phone.
It doesn't happen when running in the simulator through Xcode, or even when running the app for release on the simulator through Xcode.

Does anyone know what to do about this?

我检查了我的应用程序的签名版本,以确保定义了这些 URL 方案。
我还添加了“google”作为每个 URL 方案的标识符,因为我看到这就是示例 Google 登录应用程序中所做的。

这只发生在我构建我的应用程序的签名版本并在我的手机上进行临时安装时。
通过 Xcode 在模拟器中运行时不会发生这种情况,甚至在通过 Xcode 在模拟器上运行要发布的应用程序时也不会发生这种情况。

有谁知道该怎么办?

Other info that might be useful:
I'm using the Google Sign-In library without cocoapods.
I dragged the library bundle and framework into my project.

Also, I'm using a generic provisioning profile which contains a wildcard in the App ID, and for some reason when I build the signed version of the app the bundle ID of my app gets changed to have the wildcard in it.
i.e. the bundle id gets changed from com.example.app to com.example.*.
Because of this, I added in a third URL scheme which contains the wildcard.

其他可能有用的信息:
我正在使用没有 cocoapods 的 Google 登录库。
我将库包和框架拖到我的项目中。

此外,我正在使用一个通用配置文件,它在应用程序 ID 中包含一个通配符,并且出于某种原因,当我构建应用程序的签名版本时,我的应用程序的包 ID 被更改为在其中包含通配符。
即捆绑 ID 从 com.example.app 更改为 com.example.*。
因此,我添加了包含通配符的第三个 URL 方案。

回答by sahiljain

Adding it

添加它

1. Under Project  -> Info -> URL Types     
2. Create new url types
3. Under URL scheme add your bundle identifier.

This resolves the issue.

这解决了这个问题。

回答by ironRoei

enter image description here

在此处输入图片说明

So i had that problem for a couple of hours and then i did what you can see in the pic. Just opened anther URL type and in the schemes add the bundle identifier.

所以我遇到了这个问题几个小时,然后我做了你在图片中看到的。刚刚打开另一个 URL 类型并在方案中添加包标识符。

回答by user3798820

Okay so I finally figured out the issue. I'm almost positive the issue was the generic provisioning profile I was using. When I created a provisioning profile that was specific to my app and removed the URL scheme with the wildcard, I no longer had that problem.

好的,所以我终于弄清楚了这个问题。我几乎肯定这个问题是我使用的通用配置文件。当我创建一个特定于我的应用程序的配置文件并删除带有通配符的 URL 方案时,我不再遇到这个问题。