BarButton ItemNot Showing iOS 13 XCode 11.5

@Gryffin

Got it working.

Gimme a yell via email or here when you wake up.

Man that was a head scratcher.

I had to add SideMenu back into the Podfile though that wasn’t the issue. I’ll explain later.

@Gryffin

Here is a link to the revised App. https://www.dropbox.com/s/2tfq2rgytopxivb/App.zip?dl=0

To explain what I did might take a lot of typing. Maybe we can have a conversation via zoom tomorrow morning my time as it’s 11pm here now. At least I can explain in simple terms why I did what I did. I also wanted to make a suggestion to you about how you should use UserDefaults to store the logged in user in a way that actually records the userId which is important if you intend to make use of the Firestore Database to store data pertaining to that user.

Hi Chris, just got it thanks! Unfortunately, I won’t be able to do any zoom meetings in the near future at times that are convenient for the both of us. I made a bunch of posts, so instead of creating a whole thread. I’ll just type them all in this one post:

So, looking at the code you removed it from scenedelegate and moved it to view controller, adding dispatch queue with a wait time to let the view controller fully instantiate itself.

I also realized that in the scene delegate I was instantiating a new view controller instead of using the old one. So that might have also been the problem.

Upon checking, I can confirm that was the probem.

Ok, so for anyone who’s been following this, I tried both methods (Chris’s and instantiating a new one) and they both work.

So 1. You can do a dispatch queue in the view controller with a wait time to let it instantiate.

Or 2. You have to access the view controller from storyboard with name and bundle and instantiate it in scene delegate (make sure you use an identifier if you need it)

Hi Gryffin,

No worries.

Also you are right with regard to using SceneDelegate to direct the flow as that is the way that Chris Ching did it in the PhotoApp. I had forgotten about that.

With that in mind I rearranged your code a short while ago in the version I have here and this is what SceneDelegate now looks like.

import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    
    var window: UIWindow?
    
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        
        guard let _ = (scene as? UIWindowScene) else { return }
        
        checkUserLoggedIn()
    }
    
    func checkUserLoggedIn() {
        let def = UserDefaults.standard
        let is_authenticated = def.bool(forKey: "is_authenticated") // return false if not found or stored value
        
        if is_authenticated {
            transitionHome()
        }
    }
    
    func transitionHome() {
        let homeVC = UIStoryboard(name: "Main", bundle: .main).instantiateViewController(identifier: Constants.Storyboard.homeViewController) as? HomeViewController
        window?.rootViewController = UINavigationController(rootViewController: homeVC!)
        window?.makeKeyAndVisible()
    }
    
    func sceneDidDisconnect(_ scene: UIScene) {
        // Called as the scene is being released by the system.
        // This occurs shortly after the scene enters the background, or when its session is discarded.
        // Release any resources associated with this scene that can be re-created the next time the scene connects.
        // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
    }
    
    func sceneDidBecomeActive(_ scene: UIScene) {
        // Called when the scene has moved from an inactive state to an active state.
        // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
    }
    
    func sceneWillResignActive(_ scene: UIScene) {
        // Called when the scene will move from an active state to an inactive state.
        // This may occur due to temporary interruptions (ex. an incoming phone call).
    }
    
    func sceneWillEnterForeground(_ scene: UIScene) {
        // Called as the scene transitions from the background to the foreground.
        // Use this method to undo the changes made on entering the background.
    }
    
    func sceneDidEnterBackground(_ scene: UIScene) {
        // Called as the scene transitions from the foreground to the background.
        // Use this method to save data, release shared resources, and store enough scene-specific state information
        // to restore the scene back to its current state.
    }    
}

I reverted ViewController back to how it was originally and did a final test and the code works nicely.

import UIKit

class ViewController: UIViewController {
    
    var window: UIWindow?
    
    @IBOutlet weak var signUpButton: UIButton?
    
    @IBOutlet weak var loginButton: UIButton?
    
    let defaultSignUpButton = UIButton(type: .infoDark)
    let defaultLoginButton = UIButton(type: .infoLight)
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.

        setUpElements()
    }
    
    func setUpElements() {
        //styling buttons
        Style.styleFilledButton(signUpButton ?? defaultSignUpButton)
        Style.styleHollowButton(loginButton ?? defaultLoginButton)
        
    }
}

Delete Fred next time you are in the Firebase Console.
Good luck with the rest of the Application.

Hey Chris, this is exactly what I did this morning! Glad to see the revised code is working for both of us. I already deleted the Fred account, but thanks for the headsup. Really appreciated you help and considerable time investment.

Thank you,
Gryffin