前提
最終的にはGoogleカレンダーAPIを叩いて情報を引っ張りたいと思っているのですが、現時点ではGoogleにログインするだけのアプリを作っています。
サインインボタンをタップするとログイン画面が表示されて、メールアドレスとパスワードを入力(2回目以降はアカウントを選択)するとログインできる機能を実装中に以下のエラーメッセージが発生しました。 ログが吐き出されます。
参考にしたサイトは https://developers.google.com/identity/sign-in/ios/start?ver=swift です。
参考にしたというか、クライアントID以外のところはほぼコピペです。
実現したいこと
試しにユーザーネームなどをコンソールにprintさせた所、printできたのでログインはできているようです。
このエラー ログを放置しても問題は無いかも知れないのですが、解消する方法 表示させない方法があるのであれば、エラーの原因とその解消方法 このログが出てしまう原因と、このログをprintに表示させない方法をご教示いただきたいと思います。
よろしくお願いします。
発生している問題・エラーメッセージ ログ
2022-03-25 02:02:32.039823+0900 G-Calender[14235:12275928] GTMSessionFetcher invoking fetch callbacks, data {length = 271, bytes = 0x7b0a2020 22737562 223a2022 31313632 ... 3a20226a 61220a7d }, error (null)
該当のソースコード
Swift
1// AppDelegate.Swift 2 3import UIKit 4import GoogleSignIn 5 6@UIApplicationMain 7class AppDelegate: UIResponder, UIApplicationDelegate { 8 9 func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:] ) -> Bool { 10 var handled: Bool 11 12 handled = GIDSignIn.sharedInstance.handle(url) 13 if handled { 14 return true 15 } 16 17 // Handle other custom URL types. 18 19 // If not handled by this app, return false. 20 return false 21 } 22 23 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 24 // Override point for customization after application launch. 25 26 GIDSignIn.sharedInstance.restorePreviousSignIn { user, error in 27 if error != nil || user == nil { 28 // Show the app's signed-out state. 29 print("ログアウト") 30 } else { 31 // Show the app's signed-in state. 32 print("ログイン") 33 } 34 } 35 return true 36 } 37 38 // MARK: UISceneSession Lifecycle 39 40 func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 41 // Called when a new scene session is being created. 42 // Use this method to select a configuration to create the new scene with. 43 return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 44 } 45 46 func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { 47 // Called when the user discards a scene session. 48 // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 49 // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 50 } 51 52 53}
Swift
1//ViewController.swift 2 3import UIKit 4import GoogleSignIn 5 6class ViewController: UIViewController { 7 8//xxxxxxxxxはGoogle Cloud Platformで取得したクライアントID 9 10 let signInConfig = GIDConfiguration.init(clientID: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") 11 12 //サインインボタン 13 @IBAction func signIn(sender: Any) { 14 GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: self) { user, error in 15 guard error == nil else { 16 return } 17 // If sign in succeeded, display the app's main content View. 18 } 19 } 20 21 //サインアウトボタン 22 @IBAction func signOut(sender: Any) { 23 GIDSignIn.sharedInstance.signOut() 24 } 25 26} 27
認証済みドメインには何を記入したら良いのか分からなかったため、以下の画像のように「example.com」を指定しています。
試したこと
・認証済みドメインに自分が持っているWebサイトのURLのドメインを指定してみた。
・認証済みドメインに「google.com」を指定してみた。
・認証済みドメインに「クライアントID:/oauthredirect」を指定してみた。(これは指定の段階で弾かれました。)
・エラー内容でググる。(エラーを解消できる記事は見当たりませんでした。)
・AppAuth、GTMAppAuth、GoogleAPIClientForREST/Calendar などを使う方法も試しましたが、認証画面が表示されず断念しました。
・GoogleSignInのサンプルもクローンしてみたのですがビルドするとエラーが17個も出てしまい手が付けられませんでした。
→そもそもエラーではなく、ログだったので上記試した事は無駄でした。
ログを出力する命令を書いた覚えは無いので、このログがどうして出力されてしまうのか分かりません。デフォルトで出力されるものなのでしょうか?
あっても害は無さそうなのですが、printさせない事ができるのであればその方法をご教示いただきたいと思います。
よろしくお願いします。
補足情報(FW/ツールのバージョンなど)
Xcode11.6
iphoneSE
iOS13.6
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
たぶんここで定義されてると思いますが、
https://github.com/google/gtm-session-fetcher/blob/7fcd225add5457d388cdef224c2f74b6fcd28b24/Source/GTMSessionFetcher.h#L282
デバッグビルドの時だけログを出力してるような…。
・・・というありがたい追記・修正依頼をいただきました。
・・・という事は、この部分をいじればログが表示されないようにもできるのだと思います。ただ、Swift以外のプログラミング言語は全く分からない私がその部分をいじるのは危険と判断しました。ちょっと時間が空いた時にプロジェクトをコピーして、その部分だけコメントアウトしてみるとかはすると思いますが、ちょっといつになるかは分かりません。
でも何となく、その部分で「デバッグ時のみログを出す」ということをやっているのだなぁ・・・というのは想像できました。ありがとうございます。
ここまで来ると「この質問は最初から自分の勘違いで投稿してしまった」という感もありつつ、質問の内容も変わってきてしまうのですが、
アドバイスしてくださった方や、他のSwiftに詳しい方たちはどうやって「たぶんここで定義されてると思いますが、」の『ここ』にたどり着くのでしょうか?
できれば自力で『ここ』に辿り着けるようになりたいので、「こういう単語で検索すると出てくる」とか「公式のGithubはくまなく目を通して理解しろ」とか、何かしらアドバイスをいただけるとありがたいです。
しつこい質問者で申し訳ないのですが、もし差し支えなければヒントだけでも教えていただきたいと思います。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー