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

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

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

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

Q&A

0回答

475閲覧

Firebase連携後、シミュレーターに何も表示されなくなってしまいました。

runban

総合スコア152

Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

0グッド

0クリップ

投稿2022/07/02 09:43

編集2022/07/03 07:53

Firebaseにてアプリ登録後、「GoogleService-Info.plist」をアプリ内に配置してから
ビルドを行うと、シミュレーターには何も表示されず、コンソールにて下記エラー?が発生してしまいました。
こちらの解決方法をご教示いただけませんでしょうか。

2022-07-03 16:49:56.998366+0900 memoAppFIrebase5[21445:209925] 9.2.0 - [FirebaseAnalytics][I-ACS023007] Analytics v.9.2.0 started 2022-07-03 16:49:57.000873+0900 memoAppFIrebase5[21445:209925] 9.2.0 - [FirebaseAnalytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r) 2022-07-03 16:49:57.047346+0900 memoAppFIrebase5[21445:209941] 9.2.0 - [FirebaseAnalytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement 2022-07-03 16:49:57.105290+0900 memoAppFIrebase5[21445:209926] 9.2.0 - [FirebaseAnalytics][I-ACS023012] Analytics collection enabled 2022-07-03 16:49:57.106062+0900 memoAppFIrebase5[21445:209926] 9.2.0 - [FirebaseAnalytics][I-ACS023220] Analytics screen reporting is enabled. Call Analytics.logEvent(AnalyticsEventScreenView, parameters: [...]) to log a screen view event. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO (boolean) in the Info.plist 2022-07-03 16:49:57.603793+0900 memoAppFIrebase5[21445:209925] [boringssl] boringssl_metrics_log_metric_block_invoke(153) Failed to log metrics 2022-07-03 16:50:12.012043+0900 memoAppFIrebase5[21445:210216] [boringssl] boringssl_metrics_log_metric_block_invoke(153) Failed to log metrics 2022-07-03 16:50:12.307355+0900 memoAppFIrebase5[21445:210216] [boringssl] boringssl_metrics_log_metric_block_invoke(153) Failed to log metrics

追記ソースコード

mainTableViewController.swift

1import UIKit 2import Firebase 3 4class mainTableViewController: UITableViewController { 5 6 var memos: [Memo]! = [] 7 8 override func viewDidLoad() { 9 super.viewDidLoad() 10 print("成功") 11 } 12 13 override func viewWillAppear(_ animated: Bool) { 14 super.viewWillAppear(animated) 15 16 let data = Firestore.firestore() 17 data.collection("memos").getDocuments {[self] (snap, err) in 18 if let err = err { 19 print("エラーだよ") 20 return 21 } else { 22 for document in snap!.documents { 23 let data = document.data() 24 let memo = Memo.init(dic: data) 25 self.memos.append(memo) 26 } 27 } 28 } 29 self.tableView.reloadData() 30 } 31 32 // MARK: - Table view data source 33 34 override func numberOfSections(in tableView: UITableView) -> Int { 35 // #warning Incomplete implementation, return the number of sections 36 return 1 37 } 38 39 override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 40 // #warning Incomplete implementation, return the number of rows 41 return self.memos.count 42 } 43 44 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 45 let cell = tableView.dequeueReusableCell(withIdentifier: "tableViewCell", for: indexPath) 46 let memo = memos[indexPath.row] 47 48 let nameLabel = cell.viewWithTag(1) as! UILabel 49 nameLabel.text = memo.name 50 51 let textLabel = cell.viewWithTag(2) as! UILabel 52 textLabel.text = memo.text 53 54 return cell 55 } 56

AppDelegate.swift

1import UIKit 2import Firebase 3 4@main 5class AppDelegate: UIResponder, UIApplicationDelegate { 6 7 8 9 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 10 FirebaseApp.configure() 11 return true 12 } 13 14 // MARK: UISceneSession Lifecycle 15 16 func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 17 // Called when a new scene session is being created. 18 // Use this method to select a configuration to create the new scene with. 19 return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 20 } 21 22 func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { 23 // Called when the user discards a scene session. 24 // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 25 // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 26 } 27 28 29}

Memo.swift

1 2import Foundation 3import Firebase 4 5struct Memo { 6 var name: String = "" 7 var text: String = "" 8 9 init(dic: [String: Any]){ 10 self.name = dic["name"] as! String 11 self.text = dic["text"] as! String 12 } 13}

Podflle

1# Uncomment the next line to define a global platform for your project 2# platform :ios, '9.0' 3 4target 'memoAppFIrebase5' do 5 # Comment the next line if you don't want to use dynamic frameworks 6 use_frameworks! 7 pod 'Firebase/Analytics' 8 pod 'FirebaseFirestore' 9 10 # Pods for memoAppFIrebase5 11 12end

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

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

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

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

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

hoshi-takanori

2022/07/02 16:28

ソースコードも貼ってくれないと何も分かりません。
runban

2022/07/03 05:11

失礼いたしましたm(_ _)m ソースコードを追記いたしましたので、お手数お掛け致しますがご確認いただけますでしょうかm(_ _)m
hoshi-takanori

2022/07/03 05:57

Firebase からのデータ取得は非同期なので、コールバックの中で reloadData すれば良いかと。 あと、そういうのは viewWillAppear じやなくて viewadidLiad でやるのが普通では。
runban

2022/07/03 06:21 編集

viewWillAppearからviewDidLoadへ変更後、「self.tableView.reloadData()」をコールバック内(data.collection("memos").getDocuments {[self] (snap, err) inの中)に記載したのですが、エラーが解消されませんでした、、 コールバックの中、というのは、「data.collection("memos").getDocuments {[self] (snap, err) in」の中、との認識であっていますでしょうか?
hoshi-takanori

2022/07/03 07:05

コンソールに出てるのは重大なエラーには見えませんけど…。 で、シミュレーターには何も表示されませんか? データは存在しますか? print(self.memos) とかで確認すると良いかも。
runban

2022/07/03 07:53 編集

すみません、print(self.memos) を設定して実行しましたが、コンソールでは上記エラーが発生してprintが実行されませんでした。。(念の為、先ほど表示されたエラーを上記エラーに差し替えました) また、シミュレーターは画面が真っ白の状態で何も表示されません。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問