As mentioned in the comments, SPM package version 5.3 is the minimum for supporting bundle resources. If you need to maintain support for 5.1, you can add a second package file that includes support for 5.3: Package@swift-5.3.swift
.
Using your Harlow repo as a base, the new Package file will look like this:
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Harlow",
platforms: [
.iOS(.v10)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "Harlow",
targets: ["Harlow"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/shu223/Pulsator.git", .upToNextMajor(from: "0.6.3")),
.package(url: "https://github.com/schmidyy/Loaf.git", .upToNextMajor(from: "0.7.0")),
.package(url: "https://github.com/stanwood/SourceModel_iOS.git", .upToNextMajor(from: "1.3.3"))
],
targets: [
.target(
name: "Harlow",
dependencies: ["Pulsator", "SourceModel", "Loaf"],
resources: [.copy("Resources")]
),
.testTarget(
name: "HarlowTests",
dependencies: ["Harlow"]),
],
swiftLanguageVersions: [.v5]
)
This will make the Bundle.module
reference become available. You could provide a static reference to this instance available through your Bundle
extension like this:
extension Bundle {
public static var harlow: Bundle = .module
}
With that in place, you should be able to use the harlow
bundle reference to load your DefaultSettings.plist
. (Bundle.harlow.url(forResource:withExtension:)
)