首页 文章

GooglePlus登录使用Swift无法正常工作

提问于
浏览
1

我是第一次尝试快速,并希望用Facebook和谷歌加登录创建应用程序 .

我能够使用swift进行Facebook登录,但没有逐步添加谷歌登录 .

到目前为止,我已经编写了如下示例代码:

我有第一个屏幕按钮,点击它导致谷歌登录页面 -

import UIKit

class GooglePlusLogin: UIViewController,GPPSignInDelegate {

//var signIn: GPPSignIn?
override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.

    var signIn = GPPSignIn.sharedInstance()
    //var signIn:GPPSignIn = GPPSignIn.sharedInstance()
    signIn.shouldFetchGooglePlusUser = true
    signIn?.clientID = "25344945xxxx-u4ou9si6v9qrr1ogmqactepxxxxxbg9s.apps.googleusercontent.com"
    signIn?.scopes = [kGTLAuthScopePlusLogin]
    signIn?.delegate = self
    signIn?.authenticate()

}
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}
//MARK: G+

func finishedWithAuth(auth: GTMOAuth2Authentication!, error: NSError!) {

}

func didDisconnectWithError(error: NSError!) {

}


}

每当我点击该按钮时,它都会给我错误:

***由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [__ NSDictionaryM gtm_httpArgumentsString]:无法识别的选择器发送到实例0x7fb58a716480'

我在哪里做错了?我添加了具有适当客户端ID的所有框架 .

1 回答

  • 0

    您可能没有使用cocoapods来安装库?我得到了同样的错误 .

    您必须使用-ObjC链接器标志才能使其正常工作,否则缺少框架中的某些objc类别 . 但它为我打破了其他库,所以我放弃了并使用了pods .

    这是一步一步的教程:https://developers.google.com/identity/sign-in/ios/start-integrating

相关问题