Mixed-language package - how to import Swift header into Objective-C

I'm working on a package that requires mixed language functionality (an Objective-C function calls a function in a Swift class). I've divided the language files into two targets - one for Swift and the other for Objective-C.

The class called from Objective-C is declared with @objc and I can see the correct header is emitted for this class. I attempt to import this file into the Objective-C code as noted in this article

However, when I attempt to import the emitted header into the Objective-C file, Xcode keeps saying this file can't be found. I assume this is because it's in another target in the same package. I can manually copy the emitted header directly into the package directory and then everything works correctly, but this isn't a sensible long-term solution.

I assume there's something I need to do to make Xcode look in the correct directory for the emitted header - any suggestions/solutions?

Replies

I found a helpful article here:

https://developer.apple.com/documentation/swift/importing-swift-into-objective-c

  • Thanks, but that's the article I quoted in my original question. I've used that method, but unfortunately in our case it requires a manual step to complete (because the source is in a package). We would prefer the build process was completely automatic.

Add a Comment