我正在使用谷歌登录SDK 4.0.1.当我按下谷歌登录按钮时,应用程序就会崩溃.并给出了以下错误,如何修复:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Your app is missing support for the following URL schemes: com.googleusercontent.apps.107731993306-6s44u18onibp6gi0ddj94si1aifshhg6'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000101ac0d4b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010110121e objc_exception_throw + 48
    2   CoreFoundation                      0x0000000101b2a2b5 +[NSException raise:format:] + 197
    3   xxxxx                           0x000000010084b3cb -[GIDSignIn signInWithOptions:] + 246
    4   xxxxx                           0x000000010084efc2 -[GIDSignInButton pressed] + 242
    5   UIKit                               0x00000001028f78bc -[UIApplication sendAction:to:from:forEvent:] + 83
    6   UIKit                               0x0000000102a7dc38 -[UIControl sendAction:to:forEvent:] + 67
    7   UIKit                               0x0000000102a7df51 -[UIControl _sendActionsForEvents:withEvent:] + 444
    8   UIKit                               0x0000000102a7ce4d -[UIControl touchesEnded:withEvent:] + 668
    9   UIKit                               0x0000000102965545 -[UIWindow _sendTouchesForEvent:] + 2747
    10  UIKit                               0x0000000102966c33 -[UIWindow sendEvent:] + 4011
    11  UIKit                               0x00000001029139ab -[UIApplication sendEvent:] + 371
    12  UIKit                               0x000000010310072d __dispatchPreprocessedEventFromEventQueue + 3248
    13  UIKit                               0x00000001030f9463 __handleEventQueue + 4879
    14  CoreFoundation                      0x0000000101a65761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    15  CoreFoundation                      0x0000000101a4a98c __CFRunLoopDoSources0 + 556
    16  CoreFoundation                      0x0000000101a49e76 __CFRunLoopRun + 918
    17  CoreFoundation                      0x0000000101a49884 CFRunLoopRunSpecific + 420
    18  GraphicsServices                    0x00000001074cfa6f GSEventRunModal + 161
    19  UIKit                               0x00000001028f5c68 UIApplicationMain + 159
    20  xxxxxxxx                           0x00000001007c449f main + 111
    21  libdyld.dylib                       0x0000000104d5368d start + 1
    22  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException`

我的AppDelegate.SWIFT是

class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
public func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
   if (error == nil) {

    let userId:NSString = user.userID as NSString;                  // For client-side use only!
    let idToken: NSString = user.authentication.idToken as NSString; // Safe to send to the server
    let fullName:NSString = user.profile.name as NSString;
    let givenName:NSString = user.profile.givenName as NSString;
    let familyName:NSString = user.profile.familyName as NSString;
    let email:NSString = user.profile.email as NSString;
    print(userId)
    print(userId,idToken,fullName,givenName,familyName,email)
    }

   else {
    print("\(error.localizedDescription)")
    }
}

var window: UIWindow?

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

    let kclientID:NSString = "107731993306-xxxxxxxxxxxxxxxxx.apps.googleusercontent.com"

   GIDSignIn.sharedInstance().clientID = kclientID as String!

    GIDSignIn.sharedInstance().delegate = self
    return true
}


func application(application: UIApplication,
                 openURL url: NSURL, options: [String: AnyObject], annotation:Any, sourceApplication:String?) -> Bool {

    return GIDSignIn.sharedInstance().handle(url as URL!, sourceApplication:sourceApplication, annotation: annotation)
} 

请给我解决方案.为什么它会坠毁?

推荐答案

正如错误清楚地指出的那样,您的应用程序缺少对URL方案的支持.

将以下方案添加到您的信息中.普利斯特

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>***Your bundle ID***</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>com.googleusercontent.apps.107731993306-6s44u18onibp6gi0ddj94si1aifshhg6</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>***Something here***</string>
        </array>
    </dict>
</array>

Check this url for your id => https://developers.google.com/identity/sign-in/ios/start-integrating

Your info.plist should look like ->

enter image description here

Ios相关问答推荐

如何保持拖动预览与原始项目完全相同?

AlGolia InstantSearch Swift Package Manager引发编译错误

如何在KMM项目中处理PHPickerViewController的回调?

Swift - 缺少函数参数在编译期间不会失败,甚至会导致不同的数据类型?

Xcode14 启动时崩溃:dyld:库未加载:/usr/lib/swift/libswiftCoreGraphics.dylib

如何仅更改一个视图的导航标题 colored颜色 ?

为什么我不能让 passthrough 科目为 combine 工作?

XCode 14 Beta 中 NavigationStack 的正文渲染问题

将 SwiftUI 与 @AppStorage 和动态函数调用一起使用

在 Swift 中执行 while 循环

快速禁用 UITextfield 的用户输入

将图像保存到 Documents 目录并检索邮箱附件

导航控制器自定义过渡动画

如何用 Swift 圆化 UILabel 的边缘

将 iPhone xib 转换为 iPad xib?

命令 /Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang 失败,退出代码为 1

Sierra 中的安全/协同设计: keys 串忽略访问控制设置和 UI 提示权限

Swift - 获取设备的 WIFI IP 地址

检测应用程序何时进入我的视图背景的最佳方法是什么?

如何找到 UILabel 的实际行数?