Greetings, my first post, so please excuse any errors in protocol.
Problem: I have been trying to find the correct way to specify the publicHeadersPath in a library package I am dragging together.
Environment: Xcode 14.2; macOS 13.1; arm64
Error message: x-xcode-log://β¦ public headers ("include") directory path for 'AccessLibPq' is invalid or not contained in the target
Relevant file and directory structure detailed below.
Ramblings: This is my first serious lurch into Swift and I am reprising an old project to interface with the PostgreSQL runtime library libra.a
I have gone for the extra difficulty points here since my posters server is build from source (ie., not Homebrew) so I cannot use the usual bundling tricks I have seen in my research so far.
My current strategy is to have my c-lang shims compiles and bundled into the libpq.a library with a rename. And then access this from Swift.
Question: what do I have to do to get the publicHeadersPath specified properly?
Many thanks in advance for any help you can offer
Gavan Schneider
On 9 Jan 2023, at 5:41, Jordan Rose via Swift Forums wrote:
The path is relative to where the Package.swift file lives, so it should work if you just say βSources/includeβ!
Thx. And thatβs pretty much what I thought 2 days ago. Same error. I cannot even think how many ways I have twisted this aroundβ¦ the time has not been totally wasted as I got better at understanding the syntax, but I cannot find a way past this error.
My fear is this is not a well trodden path. There is a well established, and well blogged, process for accessing packages via url (eg., GitHub) and for using libraries that have been installed by a package manager (eg., Homebrew). I have yet to find anyone offering a recipe on how to do what I am attempting, namely packaging a library which is outside these systems Hence the post.
I wonder if I have to learn how to simulate being my own package manager. Any other thoughts?
Ah, I'm not a package manager expert, but reading more closely it wants you to put the include directory in with your per-target source files: Sources/AccessLibPq/include. (Remember, a package can have multiple targets, and each one could have its own set of headers.)
Yes it is a PITA error message: is the public headers path invalid? or, is it not contained in the target? or, both of these?
Below are my latest efforts. A lot of over specification, no syntax errors, and the same public headers error. And, just to be certain, it persists despite closing Xcode, deleting DerivedData and .swiftpm directories, and project reopening.
I can't find anything in the PackageManager API that would have me do anything else.
FWIW I have kept the header file in the include directory since omitting it has generated other complaints (but it's a hard link so they will remain the same).
I am proposing that my attempt to wrap a compiled library was doomed to failure.
I am guessing that when Swift finds the "header.h" file referring to a lot of functions it cannot see in the available source code it determines the header file is wrong... and no correspondence will be entered into. There may be a better error message for this but I'll let others decide.
Give something over 100 views I feel comfortable that there is no newby gotcha on my part, and therefore no easy fix. So thank you for looking.
I do have access to the source (after all I am complaining the server from source), bit it is a formidable exercise splitting out what is needed. Luckily this has been done already: decision-labs / libpq.framework,
It's a bit old but the fundamentals haven't changed. So my immediate problem has a solution.