SwiftPM binary target resource bundles

It would be nice if there was an SPM friendly way of including resource bundles that are meant to be distributed with pre-built binaries. For example, I have a .binaryTarget() that also requires a .bundle. Currently, the bundle has to be copied and manually dropped into the xcode project.

Ideally, we could include this in the swift package to avoid that manual process. What if we had a resources array where resources could be added to the main bundle? Something like:

let package = Package(
  name: "MyPackage",
  platforms: [.iOS(.v11)],
  products: [
    .library(name: "MyLibrary", targets: ["MyLibrary"])
  ],
  dependencies: [],
  targets: [
    .binaryTarget(name: "MyLibrary", url: "<url>/MyLibrary.xcframework.zip", checksum: "<checksum>"),
  ],
  resources: [
    .bundle(name: "MyBundle", url: "<url>/MyBundle.bundle.zip", checksum: "<checksum>"),
  ]
)
2 Likes