Extend AppDelegate from Objective-C to Swift

Hemanth Alluri
Mac O’Clock
Published in
2 min readSep 17, 2020
Extension always help to find new way
Extension Always Help to find new way :)

If your AppDelegate is written in Objective-C and you are looking to write an extension to support Swift, this article is for you..

Step One:

Create a new swift file — example, AppDelegateExtension.swift , and add the following code snippet.

AppDelegateExtension.swift

Note: Don’t forget to include public access specifier, else methods inside extension cannot be accessed in Objective-C file.

Step Two:

In your AppDelegate.m, you can call extension methods. See the below code snippet

AppDelegate.m

Step Three:

In your AppDelegate.m, add the following header.

import "Objective C generated Interface Header Name"

You can get this value from: Build Settings -> Swift Compiler General

That’s it folks.. hope you like this. :)

--

--