Call an AppDelegate.swift function from a .m file. Objective-c mixed with swift


I'm doing an app in swift , but I had to use a library that is only in objective-c , so I had to create a file .h and another file .m

The problem is that from the file .m I have to call a function of AppDelegate that is in swift but I do not know how to call it, because it tells me that AppDelegate is not declared.

How can I do it?

asked by 29.09.2016 в 13:41

2 answers


There is a header that is generated automatically when you compile.

#import "ModuleName-Swift.h"

ModuleName depends on the name of your project. If your project is called TestProyect, it will be TestProyect-Swift.h

answered by 24.10.2016 / 11:19

I have not done the test, but according to the documentation it is possible that both codes coexist in the same project.

I leave the documentation of Apple: link


answered by 13.10.2016 в 15:49