So I am trying to link to a static library from a Swift package running inside a docker container.
I have done the following:
-
built the library using make as a libfoo.a file
-
created a foo.pc file (pkg-config) to specify the appropriate include and linking flags:
prefix=/
libdir=${prefix}/lib
includedir=${prefix}/include
Name: foo
Version: 1.0.0
Cflags: -I${libdir} -I${includedir}
Libs: -L${libdir} -lawsiot
-
added the path to foo.pc to my PKG_CONFIG_PATH
ENV PKG_CONFIG_PATH=$LIB_PATH
-
specified the library as a system library target in my Package.swift
.systemLibrary(
name: "Foo",
pkgConfig: "foo")
When I try to build this project, I get the following error:
'swift-client' /swift-client: error: Source files for target Foo should be located under 'Sources/Foo', or a custom sources path can be set with the 'path' property in Package.swift
Is there something I am missing in order to make this work?
I don't think you're doing it right, check out the SPM docs.