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

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.



Hacking with Swift is sponsored by Play

SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!

Click to learn more about Play!

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.