However, as soon as I am trying to use any of its functions, the linking fails with an error such as:
ld: warning: Could not find or use auto-linked library '/usr/local/Cellar/gettext/0.22.3/lib/libintl.dylib': library '/usr/local/Cellar/gettext/0.22.3/lib/libintl.dylib' not found
ld: Undefined symbols:
_libintl_setlocale, referenced from:
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "GetTextSwift",
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "GetTextSwift",
targets: ["GetTextSwift"]
),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.systemLibrary(name: "cgettext", providers: [
.brew(["gettext"]),
.apt(["gettext"]),
]),
.target(
name: "GetTextSwift", dependencies: [
"cgettext"
]
),
.testTarget(
name: "GetTextSwiftTests",
dependencies: ["GetTextSwift"]
),
]
)
And now calling it with swift test -Xlinker -L/opt/homebrew/lib/ works perfectly.
I will experiment more. My end goal of this experiment is to be able to wrap system provided gettext in an easy to import swift package on all swift supported OSes. I am just not too sure how realistic that would be now.