How to use a compiled framework on Linux?

linux
spm

(Braden Scothern) #1

I am currently experimenting with getting a swift framework working on linux and keep getting the error: no such module 'MyLib'. I am wondering if anyone has some ideas for me to help me get it working. Here is what I have done so far:

I have created a simple package called MyLib with just a static function that prints "Hello World". I compile it and then manually bundle it into a minimal MyLib.framework while matching the format generated by Xcode for macOS. It has this layout:

MyLib.framework/
    Modules -> Versions/Current/Modules
    MyLib -> Versions/Current/MyLib
    Versions/
        A/
            Modules/
                MyLib.swiftmodule/
                    x86_64.swiftdoc
                    x86_64.swiftmodule
            MyLib
        Current -> A

I have then created a simple test package that just calls the function from MyLib. I have been compiling it with the package manager with this command:
swift build -Xswiftc -F -Xswiftc [path_to_ MyLib_dir] -Xswiftc -framework -Xswiftc MyLib

If I then run the executable it works great. Following the same steps on linux always just results in the no such module error.

Are frameworks supported on linux? If so does anyone know what else am I missing or what I need to adjust?