Use of undeclared type in Swift from Objective-C

Use of undeclared type in Swift from Objective-C Image

If you are running into the error of “Use of undeclared type” trying to use an Objective-C object in Swift, then the problem might be due to the bridging header between Swift and Objective-C not actually working properly. When you use the bridging header between Swift and Objective-C to import Objective-C objects into Swift the objects aren’t always imported properly all the time. Instead this “problematic” import may lead to some Objective-C objects being imported into the Swift class you are using and not others, leading to the “Use of undeclared type” problem with Objective-C objects.

How to resolve this when you are having this problem is to import the framework again from Swift. This will do a proper import of the Objective-C class and the “Use of undeclared type” problem should disappear from your iOS program. See the video below for more details.

Chad Jones Photo
Chad Jones Photo
About the Author

Chad Jones

Chad is the Founder and CEO at Push and was a former Apple Engineer before returning to Saskatchewan to revolutionize the mobile development world. Chad is passionate about creating efficient, well-designed software.