解決したいこと
https://www.youtube.com/watch?v=KEvA0sSpOMo&t=75sこの動画を見ながらやり8分35秒のところで実行しようとしたのですがAuth.auth().createUser...のAuthに赤線が引かれてCannot find 'Auth' in scopeとエラーが出たのですがどうすれば解決しますか?
試したこと
ターミナルでpod updeteと再度打ち直した
コード(ViewController側)
import UIKit import Firebase class ViewController: UIViewController { @IBOutlet weak var emailTextField: UITextField! @IBOutlet weak var passwordTextField: UITextField! @IBOutlet weak var usernameTextField: UITextField! @IBOutlet weak var registerButton: UIButton! @IBAction func tappedRegisterButton(_ sender: Any) { handleAuthToFierbase() } private func handleAuthToFierbase() { guard let email = emailTextField.text else {return} guard let password = passwordTextField.text else {return} Auth.auth().createUser(withEmail: email, password: password) { (res, err) in if let err = err { print("認証情報の保存に失敗しました。(err)") return } print("認証情報の保存に成功しました。") } } override func viewDidLoad() { super.viewDidLoad() registerButton.layer.cornerRadius = 20 emailTextField.delegate = self passwordTextField.delegate = self usernameTextField.delegate = self NotificationCenter.default.addObserver(self, selector: #selector(showKeyboard), name: UIResponder.keyboardWillShowNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(hideKeyboard), name: UIResponder.keyboardDidHideNotification, object: nil) } @objc func showKeyboard(notitfication: Notification) { let keyboardFrame = (notitfication.userInfo![UIResponder.keyboardFrameEndUserInfoKey] as AnyObject).cgRectValue guard let KeyboardMinY = keyboardFrame?.minY else {return} let registerButtonMaxY = registerButton.frame.maxY let distance = registerButtonMaxY - KeyboardMinY + 20 let tranceForm = CGAffineTransform(translationX: 0, y: -distance) UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: [], animations: { self.view.transform = tranceForm }) } @objc func hideKeyboard() { UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: [], animations: { self.view.transform = .identity }) } override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { self.view.endEditing(true) } } extension ViewController: UITextFieldDelegate { func textFieldDidChangeSelection(_ textField: UITextField) { let emailIsEmpty = emailTextField.text?.isEmpty ?? true let passwordIsEmpty = passwordTextField.text?.isEmpty ?? true let usernameIsEmpty = usernameTextField.text?.isEmpty ?? true if emailIsEmpty || passwordIsEmpty || usernameIsEmpty { registerButton.isEnabled = false registerButton.tintColor = UIColor.init(red: 255 / 255, green: 221 / 255, blue: 187 / 255, alpha: 1) } else { registerButton.isEnabled = true } print("textField.text: " , textField.text) } }
コード(Podfile側)
target 'timefirebase' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! # Pods for timefirebase pod 'Firebase/Analytics' pod 'Firebase/Auth' pod 'Firebase/Firestore' target 'timefirebaseTests' do inherit! :search_paths # Pods for testing end target 'timefirebaseUITests' do # Pods for testing end end
あなたの回答
tips
プレビュー