A package wrapper for a 3rd party system library

I'm creating a Swift wrapper package around a 3rd party C library. The library (let's call it xxx) is installed separately using a standalone installer package. It does not come with header files or pkg-config file. I downloaded the header files from the library source repo, created a modulemap file:

	module Cxxx [system] {
		header "include/xxx.h"
		link "xxx"
		link "xxx-util"
		export *
	}

and included them into the package source tree. My Package.swift looks like this:

	import PackageDescription

	let package = Package(
		name: "XXX",
		products: [
			.library(
				name: "XXX",
				targets: ["XXX"]),
		],
		targets: [
			.systemLibrary(name: "Cxxx"),
			.target(
				name: "XXX",
				dependencies: ["Cxxx"],
				cSettings: [
					.headerSearchPath("../Cxxx/include"),
					.headerSearchPath("../Cxxx/lib/include"),
				]),
			.testTarget(
				name: "XXXTests",
				dependencies: ["XXX"]),
		]
	)

When I include my package into my app in Xcode, the library fails to build because Xcode cannot find the header files -- it seems to ignore header search paths specified in the Package.swift, and it cannot find the library files to link to (despite that the libraries are in /usr/local/lib)

Could you please tell me if what I'm trying to do here is even possible with the current version of SPM? If it is possible, what am I doing wrong? Thank you.

Terms of Service

Privacy Policy

Cookie Policy