Post

Replies

Boosts

Views

Activity

Compiling issues with Firebase and Xcode
I am creating an app that uses firebase on Xcode. I installed the 64 bit version I read others recommended on the new M1 Macs and every time I open up my computer again, I get 15 errors of 'Redefinition of Firebase' in all files like the modulemap, object.h, dispatch.h, CFNetwork.h, AXFoundation.h as well as 'Could not build module 'CoreFoundation' I am not sure what to do since I am new to the swift language and Xcode. I have not been using the workspace rather the project and it worked the first time I installed it. I also tried uninstalling and redoing the pod install, but to no avail. I would like my code to work as I am just trying to make a way for others to sign in so I can build the rest of the app. Thanks!
1
0
845
Feb ’22
I am unsure how to look at a view controller in the simulator or preview
I am building a project right now. I have built various views and started going on YouTube to create view controllers for a log in screen. Every time I run the simulator I can't see the view controller for the log in screen to see my progress, instead, it runs the views I made for the content view. How can I display the View Controller in the preview or simulator? This log in file I am working does not show up in either and I would like to see my progress. Please let me know what is going on. Thanks! import UIKit class LogInViewController: UIViewController {          private let scrollView: UIScrollView = {         let scrollView = UIScrollView()         scrollView.clipsToBounds = true         return scrollView     }()          private let imageView: UIImageView = {         let imageView = UIImageView()         imageView.image = UIImage(systemName: "message.fill")         imageView.contentMode = .scaleAspectFit         return imageView     }()          private let emailField: UITextField = {         let field = UITextField()         field.autocapitalizationType = .none         field.autocorrectionType = .no         field.returnKeyType = .continue         field.layer.cornerRadius = 12         field.layer.borderWidth = 1         field.layer.borderColor = UIColor.lightGray.cgColor         field.placeholder = "Enter your email address"         field.leftView = UIView(frame: CGRect(x: 0, y: 0, width: 5, height: 0))         field.leftViewMode = .always         field.backgroundColor = .white         return field     } ()          private let passwordField: UITextField = {         let field = UITextField()         field.autocapitalizationType = .none         field.autocorrectionType = .no         field.returnKeyType = .done         field.layer.cornerRadius = 12         field.layer.borderWidth = 1         field.layer.borderColor = UIColor.lightGray.cgColor         field.placeholder = "Enter your password"         field.leftView = UIView(frame: CGRect(x: 0, y: 0, width: 5, height: 0))         field.leftViewMode = .always         field.backgroundColor = .white         field.isSecureTextEntry = true         return field     } ()     private let loginButton: UIButton = {         let button = UIButton()         button.setTitle("Log In", for: .normal)         button.backgroundColor = .link         button.setTitleColor(.white, for: .normal)         button.layer.cornerRadius = 12         button.layer.masksToBounds = true         button.titleLabel?.font = .systemFont(ofSize: 20, weight: .bold)         return button     }()               override func viewDidLoad() {         super.viewDidLoad()         title = "Log In"         view.backgroundColor = .white                  navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Register",                                                         style: .done,                                                         target: self,                                                         action: #selector(didTapRegister))         loginButton.addTarget(self,                               action: #selector(loginButtonTapped),                               for: .touchUpInside)                  //hitting return calls the log in function         emailField.delegate = self         passwordField.delegate = self                                    // add fields subview         view.addSubview(scrollView)         scrollView.addSubview(imageView)         scrollView.addSubview(emailField)         scrollView.addSubview(passwordField)         scrollView.addSubview(loginButton)     }     //lay out on screen     override func viewDidLayoutSubviews() {         super.viewDidLayoutSubviews()         scrollView.frame = view.bounds         let size = scrollView.width/3         imageView.frame = CGRect(x: (scrollView.width-size)/2,                                  y: 20,                                  width: size,                                  height: size)         emailField.frame = CGRect(x: 30,                                   y: imageView.bottom + 10,                                   width: scrollView.width - 60,                                   height: 52)         passwordField.frame = CGRect(x: 30,                                   y: emailField.bottom + 10,                                   width: scrollView.width - 60,                                   height: 52)         loginButton.frame = CGRect(x: 30,                                    y: passwordField.bottom + 10,                                    width: scrollView.width - 60,                                    height: 52)     }          @objc private func loginButtonTapped() {                  emailField.resignFirstResponder()         passwordField.resignFirstResponder()         guard let email = emailField.text,                 let password = passwordField.text,               !email.isEmpty, !password.isEmpty, password.count >= 6 else {                   return               }     }          func alertUserLoginError() {         let alert = UIAlertController(title: "Didn't quite crack the code",                                       message: "Please enter all info to log on",                                       preferredStyle: .alert)         alert.addAction(UIAlertAction(title: "Dismiss",                                       style: .cancel,                                       handler: nil))         present(alert, animated: true)     }          @objc private func didTapRegister() {         let vc = RegisterViewController()         vc.title = "Create Account"         navigationController?.pushViewController(vc, animated: true)     } } extension LogInViewController: UITextFieldDelegate {     func textFieldShouldReturn(_ textField: UITextField) -> Bool {                  if textField == emailField {             passwordField.becomeFirstResponder()         } else if textField == passwordField {             loginButtonTapped()         }         return true     }
1
0
430
Jan ’22