Access delegate protocol from Swift framework into Objective C

Ask A Question

Login To post a question

I’ve created the Swift framework and integrated into ObjC project.

Now, I want to pass/access delegate handler in ObjC.

Swift Framework contains UIViewController with close and submit button.

ListViewController.swift SwiftFramework

public protocol ListHandler {
    func submit(options: String)
    func close()

public class ListViewController: UIViewController {

    public var handler: ListHandler?

    @objc func dismiss(_ sender: UIButton) {

    @objc func submit(_ sender: UIButton) {
        handler?.submit(options: "Done")

Created MyApp-Bridginh-Header.h
And SwiftWrapper.swift to show ListViewController

import SwiftFramework

@objc public class SwiftWrapper: NSObject {

    @objc public var controller: ListViewController?

    override init() {

    @objc public func showListScreen() -> UIViewController {

        self.controller = ListViewController(title: "List")

          IMPORTANT: How I can pass this to ObjC called controller?
        // self.controller?.handler =
        return self.controller!

Finally in objC view controller, able to show List screen but can’t pass delegate and handle submit/close button actions.


#import "MyApp-Swift.h"

SwiftWrapper *wrapper = [[SwiftWrapper  alloc] init];

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:[wrapper showListScreen]];
[self presentViewController:navController animated:YES completion:nil];

How to access here?

Example project repository:
Swift Framework:
ObjC project:

Appreciate your help and suggestions.


For more info please click here

Have a question or need a custom quote?