NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

Swift on Sundays: Friendzone - AppDelegate or SceneDelegate?

Forums > Books


I've been following the FriendZone chapter in Swift on Sundays, but haven't been able to get the coordinator working. I think it is due to the code to create the coordinator, which the book says to add to the willConnectTo method of SceneDelegate.swift. I took a look at the GitHub repository for this app to see where I was going wrong, and this doesn't have a SceneDelegate.swift, and instead the code is in AppDelegate.swift. I also tried removing SceneDelegate.swift from my project and putting the logic in AppDelegate, but that didn't work either. So I'd really just like to know why the difference between the GitHub repo and the book, and which is correct.


The github repository was last updated 16 months ago, which is prior to WWDC19 introducing the new SceneDelegate class and way of doing things. The book, however, was last updated in Feb 2020 and therefore includes SceneDelegate and the new method.


I found the solutiom by looking at someone else's version in GitHub. It seems that in SceneDelegate, instead of:

window = UIWindow(frame: UIScreen.main.bounds)

I should be doing:

guard let windowScene = (scene as? UIWindowScene) else { return } // this line already there ... window = UIWindow(windowScene: windowScene)


Thanks for posting that solution, I was having the same problem!


Hacking with Swift is sponsored by Judo

SPONSORED Let’s face it, SwiftUI previews are limited, slow, and painful. Judo takes a different approach to building visually—think Interface Builder for SwiftUI. Build your interface in a completely visual canvas, then drag and drop into your Xcode project and wire up button clicks to custom code. Download the Mac App and start your free trial today!

Try now

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.