I have a multi-platform (MacOS, linux) library project that requires resources (images, data files) to be bundled with the library. What is the current practice of providing and installing libraries with resources that works on Linux as well as MacOS (and eventually on Windows in the future)?
I tried to create a simple package:
let package = Package(
name: "restest",
products: [
.library(
name: "ResTestLib",
targets: ["ResTestLib"]
),
.executable(
name: "restest",
targets: ["restest"]
)
],
targets: [
.target(
name: "ResTestLib",
resources: [.copy("Resources/data.txt")],
),
.executableTarget(
name: "restest",
dependencies: ["ResTestLib"],
),
]
)
When running the locally build debug version, the resource paths that I get through Bundle.module
in the ResTestLib
point to .build
directory, which is expected.
When I do swift experimental-install
(I acknowledge the 'experimental' nature), the bundle path still remains in the .build
directory.
The swift package manager documentation about resources does not seem to provide details on resource installation.
I need the resources to be bundled with the library (or with any project that includes the library). Currently there are two projects as separate packages using the library: a command-line tool and a SwiftGodot plug-in that uses the library.
My question is: What are the current practices and options of packaging and installing library resources that work at least on MacOS and Linux?