Use R.swift for resources in your own Swift package.
This is a plugin for Swift Package Manager, which supports plugins since Swift 5.6, therefore the proper swift tools needs to be used
You need two dependencies,
R.swift.Libraryas usual, but also
dependencies: [ .package(url: "https://github.com/mac-cain13/R.swift.Library", from: "5.4.0"), .package(url: "https://github.com/quentinfasquel/R.swift.Plugin", from: "5.4.0") ],
Your target needs to link with
R.swift.Libraryand use the plugin
targets: [ .target( name: "YourTarget", dependencies: [.product(name: "RswiftDynamic", package: "R.swift.Library")], resources: [ .copy("someImage.png") // Resource example ], plugins: [.plugin(name: "RswiftPlugin", package: "R.swift.Plugin")] ),
Use R.swift like before :
let image = R.image.someImage()
This plugin may not be bullet-proof since it was barely tested. It is awaiting to become officially supported by the official R.swift, here is what to know about how it works :
The SPM plugin uses an executable variant of the official R.swift. It is currently hosted through a github release built from this branch.
--accessLevel publicso that the resources of a package, and mostly
R.validate(), are accessible in the package’s test target.
The executable is slightly big (~ 24Mb) since it carries along a dependency on Swift Package Manager’s own package model
Your feedback is welcome!