NEW: Subscribe to Hacking with Swift+ and accelerate your learning! >>

Project 7: White House Petitions - Use of unresolved identifier ‘window’ in didFinishLaunchingWithOptions

Forums > 100 Days of Swift

am on project 7 on HWS and am getting this error.. followed everything like in tutorial. checked online for solutions. still couldnt get around it.

if let tabBarController = window?.rootViewController as? UITabBarController {  //use of unresolved identifier 'window'
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let vc = storyboard.instantiateViewController(withIdentifier: "NavController")
    vc.tabBarItem = UITabBarItem(tabBarSystemItem: .topRated, tag: 1)


Since Xcode 11 the new template for AppDelegate is changed. Assuming the code above goes in AppDelegate you can try adding this property to the class:

var window: UIWindow?


thanks it worked. i tried replacing window with UIwindow and got error. didnt thought about creating a variable.

found another long solution on reddit havent tried it yet.

this solved that error. and now i can build. my VM crashed. will update final results when am done fully with project.



it solved the error that prevented it from building but it didnt add the scond tab bar. gotta try the reddit solution.


Put it in scene delegate.



Thanks. Took me a minut to find the right place. I thought it might be there, but didn't really go for it until I saw your message. Got it working


Hacking with Swift is sponsored by Fernando Olivares

SPONSORED Ever ask for help and your reviewer immediately notices issues you missed? Fernando Olivares is a 10-year veteran from Big Nerd Ranch and Lambda School who can help hone your app building skills, and he's just launched a new book that does just that – use the code "hacking" to save $5!

Buy the book

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

Not logged in

Log in

Link copied to your pasteboard.