質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Q&A

0回答

432閲覧

Type of expression is ambiguous without more context

cocona15531

総合スコア6

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

0グッド

0クリップ

投稿2023/02/17 14:20

前提

Swiftで開発を始めた者です。

FirebaseでGoogle認証をしたく、公式ドキュメントを参考にしながら進めていたのですが、Type of expression is ambiguous without more contextと表示されて躓いています。どのようにすれば対処できるでしょうか。ご教示いただきたいです。

発生している問題・エラーメッセージ

イメージ説明

Type of expression is ambiguous without more context

該当のソースコード

AppDelegate.swift

1import UIKit 2import FirebaseCore 3import GoogleSignIn 4import FirebaseAuth 5 6 7@main 8class AppDelegate: UIResponder, UIApplicationDelegate { 9 10 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 11 // Override point for customization after application launch. 12 13 let ud = UserDefaults.standard 14 let firstLunchKey = "firstLunch" 15 let firstLunch = [firstLunchKey: true] 16 ud.register(defaults: firstLunch) 17 18 FirebaseApp.configure() 19 20 return true 21 } 22 23 // MARK: UISceneSession Lifecycle 24 25 func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 26 // Called when a new scene session is being created. 27 // Use this method to select a configuration to create the new scene with. 28 return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 29 } 30 31 func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { 32 // Called when the user discards a scene session. 33 // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 34 // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 35 } 36 37 func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool { 38 return GIDSignIn.sharedInstance.handle(url) 39 } 40 41 42}

loginViewController.swift

1import UIKit 2import FirebaseCore 3import GoogleSignIn 4import FirebaseAuth 5 6 7class loginViewController: UIViewController { 8 9 @IBOutlet weak var signInButton: GIDSignInButton! 10 11 override func viewDidLoad() { 12 super.viewDidLoad() 13 14 // Do any additional setup after loading the view. 15 } 16 17 @IBAction func didTapSoginButton(_ sender: Any) { 18 auth() 19 } 20 21 @IBAction func loginButton(_ sender: Any) { 22 } 23 24 @IBAction func registerButton(_ sender: Any) { 25 } 26 27 private func auth() { 28 guard let clientID = FirebaseApp.app()?.options.clientID else { return } 29 let config = GIDConfiguration(clientID: clientID) 30 31//この下の一行に出てます 32 GIDSignIn.sharedInstance.signIn(with: config, presenting: self) { [unowned self] user, error in 33 if let error = error { 34 print("GIDSignInError: \(error.localizedDescription)") 35 return 36 } 37 38 guard let authentication = user?.authentication, 39 let idToken = authentication.idToken else { return } 40 41 let credential = GoogleAuthProvider.credential(withIDToken: idToken, accessToken: authentication.accessToken) 42 self.login(credential: credential) 43 } 44 } 45 46 private func login(credential: AuthCredential) { 47 print("ログイン完了") 48 } 49 50}

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

cocona15531

2023/02/18 10:50

ありがとうございます。 同じエラーメッセージが出てしまい、解決できませんでした...
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問