`canImport` for Objective C clients of Swift Packages

Is there a way to check if a Swift module is importable from an Objective C client when using Swift Package Manager? I can't find an Objective C equivalent to #if canImport ....

In CocoaPods, it works to do #if __has_include("{MyModule-umbrella.h"). Swift PM generates a {MyModule}-Swift.h in Derived Data, but it does not seem accessible outside its own module as is documented at Apple Developer Documentation.

Is there a way to check if a Swift module is accessible at build time from Objective C when using Swift Package Manager?

2 Likes