Hi,
I'm having issues when I try to compile a Swift file and link it against a fat dynamic framework in an arm64 environment. The library is built following the steps in this blog post:
swift build --configuration release --triple arm64-apple-macosx
swift build --configuration release --triple x86_64-apple-macosx
lipo -create -output package .build/arm64-apple-macosx/release/package .build/x86_64-apple-macosx/release/package
The output tha we get from that compilation is 4 files:
ProjectDescription.swiftdoc
ProjectDescription.swiftmodule
ProjectDescription.swiftinterface
libProjectDescription.dylib
Then, the compiler command that we use is the following:
The 'swift' command exited with error code 1 and message:
/path/main.swift:1:8: error: module 'ProjectDescription' was created for incompatible target arm64-apple-macosx10.15: /path/to/module/ProjectDescription.swiftmodule
import ProjectDescription
^
Do I need any extra argument when compiling the Swift file? Of is it something related to the way the .swiftmodule of the framework is generated?
In the include path, you need to have the swiftmodule for the target you are compiling for. It seems like here you are compiling for x86_64 with the xcrun swift command, but your include path is ending up looking at the arm64 swiftmodule for ProjectDescription. Usually, the swiftmodule is a directory which contains individual swiftmodule files on a per-target basis (but it can also be a file). If you include that directory and it does have individual files for different targets, then it ought to work.
Thanks for the response @typesanitizer. One question that I have regarding the .swiftmodule is how should the files be named inside the directory? Let's say I have the following .swiftomdule s: