I'm trying to wrap libtiff
(my reposo I can call it from my Swift code. I've done this successfully before with a different library (libmodbus
), but in that case, the header and library files were in /usr/local/include/modbus
, but in this case, they're in /opt/homebrew/Cellar/libtiff/4.6.0/include/
.
I thought pkg-config
was supposed to take care of that. On my system it returns:
% pkg-config --cflags --libs libtiff-4
-I/opt/homebrew/Cellar/libtiff/4.6.0/include -I/opt/homebrew/opt/zstd/include -I/opt/homebrew/Cellar/xz/5.4.6/include -I/opt/homebrew/Cellar/jpeg-turbo/3.0.3/include -L/opt/homebrew/Cellar/libtiff/4.6.0/lib -ltiff
Note that it needs to have libtiff-4
specified. I do that in my Pacakge.swift
:
.systemLibrary(name: "libtiff", pkgConfig: "libtiff-4", providers: [.brew(["libtiff"]), .apt(["libtiff-dev"])]),
But when I try to import libtiff
in the packageβs SwiftTIFF.swift
file, it says it can't be found.
One really odd thing I notice. If I import libmodbus
instead, something it should know nothing about, it says "could not build Objective-C module 'libmodbus'".
Moreover if I introduce an error in the system library module by attempting to include <tiff1.h>
, which does not exist, I get an error, but only if Iβm attempting to import libmodbus
. If I attempt to import libtiff
, it does not fail on the tiff1.h
include, and just says "no such module 'libtiff'". If I fix the header include but leave import libmodbus
, it builds without error, so long as I don't try to import libtiff
. WTF.
This behavior is true for Xcode 16b2, and for swift build
on the command line.
This is astonishingly frustrating. Thereβs not enough information to really understand why itβs failing, and the symptoms make no sense.