#質問したいこと
Firebaseを使ったアプリを作っています。
そこで、
reason: '`[FIRApp configure];` (`FirebaseApp.configure()` in Swift) could not find a valid GoogleService-Info.plist in your project. Please download one from https://console.firebase.google.com/.'
というエラーで止まってしまいます。
#コード
######サインアップの画面(一番最初の画面です)
swift
1//accountViewcontroller 2import UIKit 3import Firebase 4import FirebaseAuth 5 6class AccountViewController: UIViewController, UITextFieldDelegate { 7 var account: FirebaseApp! 8 9 @IBOutlet private weak var nameTextField: UITextField! 10 @IBOutlet private weak var emailTextField: UITextField! 11 @IBOutlet private weak var passwordTextField: UITextField! 12 13 @IBAction private func didTapSignUpButton() { 14 let email = emailTextField.text ?? "" 15 let password = passwordTextField.text ?? "" 16 let name = nameTextField.text ?? "" 17 18 Auth.auth().createUser(withEmail: email, password: password) { [weak self] result, error in 19 guard let self = self else { return } 20 if let user = result?.user { 21 let req = user.createProfileChangeRequest() 22 req.displayName = name 23 req.commitChanges() { [weak self] error in 24 guard let self = self else { return } 25 if error == nil { 26 user.sendEmailVerification() { [weak self] error in 27 guard let self = self else { return } 28 if error == nil { 29 // 仮登録完了画面へ遷移する処理 30 // サインアップ完了のフラグを保持する 31 UserDefaults.standard.set(true, forKey: "appSignUpStatusKey") 32 UserDefaults.standard.synchronize() 33 } 34 self.showErrorIfNeeded(error) 35 } 36 } 37 self.showErrorIfNeeded(error) 38 } 39 } 40 self.showErrorIfNeeded(error) 41 } 42 // サインアップ完了のフラグを保持する 43 UserDefaults.standard.set(true, forKey: "appSignUpStatusKey") 44 // ユーザー名を保存する 45 UserDefaults.standard.set(name, forKey: "userNameKey") 46 UserDefaults.standard.synchronize() 47 if (email == "" || password == "" || name == "") { 48 let message = "全てのフォームに記入して下さい。" 49 let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert) 50 alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) 51 self.present(alert, animated: true, completion: nil) 52 } 53 } 54 55 56 private func showErrorIfNeeded(_ errorOrNil: Error?) { 57 // エラーがなければ何もしません 58 guard let error = errorOrNil else { return } 59 let message = "エラーが起きました" // ここは後述しますが、とりあえず固定文字列 60 let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert) 61 alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) 62 present(alert, animated: true, completion: nil) 63 } 64 65 66 67 68 // AccountViewControllerの想定です 69 override func viewDidLoad() { 70 super.viewDidLoad() 71 self.navigationController?.navigationBar.isHidden = true 72 73 self.nameTextField.delegate = self 74 self.emailTextField.delegate = self 75 self.passwordTextField.delegate = self 76 77 78 } 79 80 override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { 81 self.view.endEditing(true) 82 } 83} 84
######AppDelegate
swift
1//AppDelegate 2import UIKit 3import CoreData 4import Firebase 5 6@UIApplicationMain 7class AppDelegate: UIResponder, UIApplicationDelegate { 8 9 10 11 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 12 // Override point for customization after application launch. 13 FirebaseApp.configure() 14 return true 15 } 16 17 // MARK: UISceneSession Lifecycle 18 19 func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 20 // Called when a new scene session is being created. 21 // Use this method to select a configuration to create the new scene with. 22 return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 23 } 24 25 func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { 26 // Called when the user discards a scene session. 27 // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 28 // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 29 } 30 31 // MARK: - Core Data stack 32 33 lazy var persistentContainer: NSPersistentContainer = { 34 /* 35 The persistent container for the application. This implementation 36 creates and returns a container, having loaded the store for the 37 application to it. This property is optional since there are legitimate 38 error conditions that could cause the creation of the store to fail. 39 */ 40 let container = NSPersistentContainer(name: "new_timer3") 41 container.loadPersistentStores(completionHandler: { (storeDescription, error) in 42 if let error = error as NSError? { 43 // Replace this implementation with code to handle the error appropriately. 44 // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 45 46 /* 47 Typical reasons for an error here include: 48 * The parent directory does not exist, cannot be created, or disallows writing. 49 * The persistent store is not accessible, due to permissions or data protection when the device is locked. 50 * The device is out of space. 51 * The store could not be migrated to the current model version. 52 Check the error message to determine what the actual problem was. 53 */ 54 fatalError("Unresolved error (error), (error.userInfo)") 55 } 56 }) 57 return container 58 }() 59 60 // MARK: - Core Data Saving support 61 62 func saveContext () { 63 let context = persistentContainer.viewContext 64 if context.hasChanges { 65 do { 66 try context.save() 67 } catch { 68 // Replace this implementation with code to handle the error appropriately. 69 // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 70 let nserror = error as NSError 71 fatalError("Unresolved error (nserror), (nserror.userInfo)") 72 } 73 } 74 } 75 76} 77 78
######Podfileの方も
swift
1//Podfile 2# Uncomment the next line to define a global platform for your project 3platform :ios, '9.0' 4 5target 'new_timer3' do 6 # Comment the next line if you don't want to use dynamic frameworks 7 use_frameworks! 8 9 # Pods for new_timer3 10pod 'Firebase/Database' 11pod 'Firebase/Core' 12pod 'Firebase/Firestore' 13pod 'Firebase/Auth' 14pod 'Firebase/Storage' 15 target 'new_timer3Tests' do 16 inherit! :search_paths 17 # Pods for testing 18 end 19 20 target 'new_timer3UITests' do 21 # Pods for testing 22 end 23 24end 25
#やってみたこと
とりあえず、GoogleInfoPlistがダウンロードされていないと言っているような感じがしたので、もう一度ダウンロードして見たんですが、なんどやっても結果は同じく、一番最初のエラーが出てしまいます。
よろしくお願いします!!!
回答1件
あなたの回答
tips
プレビュー