FYI, we just merged a change to the SwiftPM Archiver plugin to include the executable's resources in the archive.
Feel free share your feedback about this new feature.
Thank you Camden (camdenfullmer (Camden Fullmer) · GitHub) for having proposed and implemented this change !
Motivation:
When deploying a Lambda function that generates HTML content I needed a way to package template HTML files along with the executable. Defining the resources in the Package.swift
and then packaging them in the archive in a way so that Swift can access them using Bundle.main.resourceURL
felt like the best way to accomplish this.
Example:
.executableTarget(
name: "Website",
dependencies: [
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
],
resources: [
.process("template.stencil"),
]),
Modifications:
Plugin code has been modified to generate a Contents/Resources
directory inside the final archive which includes the resources defined in the executable's target from Package.swift
.
Result:
The zip archive includes the defined resources in Package.swift
.
Code
You can check the PR or a new example project to demonstrate how to use this feature.