Problem using systemLibrary target

So I am trying to link to a static library from a Swift package running inside a docker container.

I have done the following:

  1. built the library using make as a libfoo.a file

  2. 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

  3. added the path to foo.pc to my PKG_CONFIG_PATH

    ENV PKG_CONFIG_PATH=$LIB_PATH

  4. 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.

Terms of Service

Privacy Policy

Cookie Policy