I'm trying to compile and link code against a dynamic library. It used to work until Swift 5.10. It fails on Swift 6
I build my library like this
swift build -c debug --product AWSLambdaDeploymentDescriptor
with this line in Package.swift
.library(name: "AWSLambdaDeploymentDescriptor", type: .dynamic, targets: ["AWSLambdaDeploymentDescriptor"]),
And it produces
ls .build/debug/*AWSLambdaDeployment*
.build/debug/libAWSLambdaDeploymentDescriptor.dylib
.build/debug/AWSLambdaDeploymentDescriptor.build:
AWSLambdaDeploymentDescriptor-Swift.h DeploymentDescriptor.swiftdeps FileDigest.d module.modulemap
AWSLambdaDeploymentDescriptor.emit-module.d DeploymentDescriptorBuilder.d FileDigest.swift.o output-file-map.json
DeploymentDescriptor.d DeploymentDescriptorBuilder.swift.o FileDigest.swiftdeps sources
DeploymentDescriptor.swift.o DeploymentDescriptorBuilder.swiftdeps master.priors
.build/debug/AWSLambdaDeploymentDescriptor.product:
Objects.LinkFileList
.build/debug/libAWSLambdaDeploymentDescriptor.dylib.dSYM:
Contents
When I try to compile against it
swiftc -I .build/debug -L .build/debug -lAWSLambdaDeploymentDescriptor Deploy.swift
Deploy.swift:4:19: error: cannot find 'Queue' in scope
2 |
3 | // example of a shared resource
4 | let sharedQueue = Queue(
| `- error: cannot find 'Queue' in scope
5 | logicalName: "SharedQueue",
6 | physicalName: "swift-lambda-shared-queue")
The compiler can not find the public symbols exported.
I noticed there is no .swiftmodule
being generated like before. I understand these are similar to headers files with the list of symbols. This probably explains the compiler errors I observe.
I tried to add -Xswiftc -emit-module
when compiling the dynamic library, but it doesn't generate the .swiftmodule
directory
Any idea ? How can I compile and run code that links to a dynamic library using Swift 6 ? How should I invoke the toolchain when building the library to generate required symbols to use it ?