I am trying to modernize some OpenSSL/SSH bindings that exist out in the wild to be packaged as XCFrameworks as it would allow me to ship a single package for all platforms that consume it, and today I use an assorted bag of hacks to support more than one platform. So XCFrameworks look exactly like the solution that I need.
Both libssh and openssl produce native static libraries and header files that I consume as part of the SwiftSH binding project which surfaces these low-level libraries in a Swift-friendly API. I have a fork that I am maintaining here: https://github.com/migueldeicaza/SwiftSH.
Sadly, when I create my SwiftSH.framework, the
swiftmodule file contains this line:
When I try to consume this as an XCFramework, it reports an error
No such module: Libssh2.
The SwiftSH binary that is produced by Xcode already contains all of the symbols for Libssh2 that I need.
I would like to either find a way for my
swiftmodule to not include that line
import Libssh2, or for Xcode to realize that the provided XCFramework already has the
I have been able to gather that the
swiftmodule is produced by the flag
-emit-module-interface-path passed to the swift compiler, but have not been able to figure out what goes into this, and how I can limit this from being included.
If I manually edit the
swiftmodule file with vi and removed the offending line and things work. But I am going to be laughed at if anyone finds out I am doing this, so I am trying to avoid the public ridicule.
My butchered SwiftSH is here:
And the command line invocation that produces this is here:
SIDEBAR: I did attempt to create xcframeworks for both libssh and openssl and referenced those from my main project, but the error did not go away, so I considered that a failed effort.
I uploaded these here in case it is useful to peruse the work: