iosswiftxcodeobjective-c++

Cannot import Objective C++ wrapper class into my Swift code


I have an Objective C++ wrapper class called ImageDividerWrapper in which there is a function I want to use in a Swift class called FrameProcessor.

Inside the ImageDividerWrapper.h file I made sure to import the bridging header. I also double-checked that the bridging header was referenced and spelled correctly in Project/Build Settings/Swift Compiler. I also deleted derived data, cleaned build folder, etc..

Also imported ImageDividerWrapper.h into my bridging header file:

#import "ImageDividerWrapper.h"

And in my ImageDividerWrapper header file I include:

#import "Vsn3-Bridging-Header.h"

Unfortunately, I still continue to get the error: "No such module 'ImageDividerWrapper'" when trying to directly import the Objective C++ class into my Swift file with:

import ImageDividerWrapper

If anyone who has solved this problem before can point me in the right direction, I would appreciate it so much!

Thank you!


Solution

  • My understanding is that the second import line is unnecessary. You need to just:

    1. Import the header file: #import "ImageDividerWrapper.h"
    2. Then just use the class! (e.g. let thisDivider = ImageDividerWrapper())