From 2edab222557e5243a96e70dd7244b6467ccf5d50 Mon Sep 17 00:00:00 2001 From: tannevaled Date: Sun, 31 May 2026 17:11:35 +0200 Subject: [PATCH] new(SwiftGen): code generator for Swift project resources Replace the vendored prebuilt zip with a source build via Swift Package Manager. Installs both the swiftgen executable and its sibling SwiftGen_SwiftGenCLI.bundle (Stencil templates) so Bundle.module resolves at runtime. Darwin-only (pantry's swift.org is darwin-only). Co-Authored-By: Claude Opus 4.7 --- .../github.com/SwiftGen/SwiftGen/package.yml | 44 ++++++++++++++----- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/projects/github.com/SwiftGen/SwiftGen/package.yml b/projects/github.com/SwiftGen/SwiftGen/package.yml index d90b5aa1ad..c571858261 100644 --- a/projects/github.com/SwiftGen/SwiftGen/package.yml +++ b/projects/github.com/SwiftGen/SwiftGen/package.yml @@ -1,25 +1,45 @@ +# SwiftGen — Swift code generator for project resources (assets, fonts, +# Localizable.strings, storyboards, JSON, plists, etc.). Major analog of +# pantry's github.com/mac-cain13/R.swift; ~9k-star, Apple-blessed project. +# +# Source build via Swift Package Manager (no vendoring). The executable +# target has a `resources` declaration that produces a sibling +# `SwiftGen_SwiftGenCLI.bundle` directory holding the Stencil templates. +# Both artifacts must be installed together — SwiftPM's `Bundle.module` +# loader looks for the bundle next to the binary at runtime. This matches +# Homebrew's rake `cli:install` task (cp binary + cp -R bundle). + distributable: - # FIXME: vendoring - #url: https://github.com/SwiftGen/SwiftGen/archive/refs/tags/{{version}}.tar.gz - #strip-components: 1 - url: https://github.com/SwiftGen/SwiftGen/releases/download/{{version}}/swiftgen-{{version}}.zip + url: https://github.com/SwiftGen/SwiftGen/archive/refs/tags/{{version}}.tar.gz + strip-components: 1 versions: - github: SwiftGen/SwiftGen/releases/tags + github: SwiftGen/SwiftGen +# Swift toolchain is darwin-only in pantry (see projects/swift.org). platforms: - darwin provides: - bin/swiftgen -warnings: - - vendored - build: - working-directory: ${{prefix}}/bin - script: cp -a "$SRCROOT"/bin/swiftgen "$SRCROOT"/bin/SwiftGen_SwiftGenCLI.bundle . + dependencies: + # Package.swift declares swift-tools-version:5.5; any pantry swift works. + swift.org: '*' + script: + - swift build + --configuration release + --disable-sandbox + # Install the executable and its sibling resource bundle (Stencil + # templates) into bin/. The binary resolves Bundle.module by looking + # next to itself, so the .bundle must live alongside swiftgen. + - install -D -m755 .build/release/swiftgen "{{prefix}}/bin/swiftgen" + - cp -R .build/release/SwiftGen_SwiftGenCLI.bundle "{{prefix}}/bin/" test: - script: | - [[ "$(swiftgen --version)" = "SwiftGen v{{version}}"* ]] + script: + # `swiftgen --version` prints e.g. "SwiftGen v6.6.3 (Stencil v0.15.1, ...)" + - swiftgen --version | grep -F "SwiftGen v{{version}}" + # Smoke-test the template-bundle wiring by listing bundled templates. + - swiftgen template list | grep -F "swift5"