How to Use Swift Packages in Objective-C Targets
If, as I have, you’ve started using Swift packages to reuse code amongst your projects, you may have wondered if it’s possible to use them in Objective-C projects. Fortunately, the answer is yes, provided you’re using Xcode 11.4 or newer. Just make sure you use the @import syntax in your ObjC file, not the older #import style, and it should work as expected.
One thing to note, I’ve found that autocomplete doesn’t seem to work consistently, which is understandable for such a recent feature addition. Bearing that in mind, if you start to think things aren’t hooked up properly because Xcode doesn’t seem aware of the package contents, just write some code, double check the syntax, build and it should run fine.
If you’re new to Swift packages in general, also be aware that classes and functions should be marked as public to be visible and usable outside the package, as they are designated as internal by default. And, of course, remember to use the @objc attribute so your Swift code is accessible within the Objective-C runtime.