WWDC23 SALE: Save 50% on all my Swift books and bundles! >>

SOLVED: UIKit Project 32 - "Use of unresolved identifier window" in AppDelegate

Forums > Books

So at the end of the chapter, to handle activation events coming from Spotlight, we're told to place the following into our AppDelegate class:

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
    if (userActivity.activityType == CSSearchableItemActionType) {
        if let uniqueIdentifier = userActivity.userInfo?[CSSearchableItemActivityIdentifier] as? String {
            if let navigationController = window?.rootViewController as? UINavigationController {
                if let viewController = navigationController.topViewController as? ViewController {

    return true

Even copying right out of the book, however, it indicates that window is an unresolved identifier, and shows a compiler error.

Is this a version/upgrade issue, or should there be a property added to AppDelegate to handle this?


Hi, starting with iOS 13, handing these is done in SceneDelegate. You should all the method there with modifications.

func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {



That did it! Only other note, besides of course moving over the import CoreSpotlight call is to remove the return true call at the end of the function, since the new version is a void function.



Save 50% in my WWDC23 sale.

SAVE 50% To celebrate WWDC23, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

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.