The name of the dynamic library (.so file) generated by SwiftPM depends on the name in the .library product.
.library(
name: "my-module", // This name is used for the file: libmy-module.so
type: .dynamic,
targets: ["MyModule"]
)
However, SwiftJava currently uses the module name for System.loadLibrary. In the example above, it tries to load libMyModule.so, which causes an error because the file does not exist.
public final class MySwiftClass implements JNISwiftInstance {
static final String LIB_NAME = "MyModule"; // Should be "my-module"
static boolean initializeLibs() {
System.loadLibrary(SwiftLibraries.LIB_NAME_SWIFT_JAVA);
System.loadLibrary(LIB_NAME); // Error
return true;
}
}
Expected Behavior:
I think we should have one of the following:
- Use the library (product) name for code generation instead of the module name.
- Or, show an error if the library name and module name are different (or if there are multiple modules).