Skip to content

Instantly share code, notes, and snippets.

View GeroHerkenrath's full-sized avatar

Gero Herkenrath GeroHerkenrath

View GitHub Profile
@GeroHerkenrath
GeroHerkenrath / ScriptHelper.swift
Created April 22, 2025 13:49
Demo for Swift scripts that import other (.swift) helper files to make code easier to reuse. Works by compiling the helpers to a module first.
/// This file contains some helper properies, functions, and types that make writing other scripts a lot easier.
/// Put this and the related `rebuildBinaries.swift` file into a folder named "ScriptHelper" on the same level as
/// the scripts or adapt the paths below accordingly.
///
/// To then use the helper in a Swift script you need to do three things:
/// 1. Compile it into an importable module
/// 2. Make it visible and linkable to your script and import it in its code
///
/// For the first point there is a helper script provided, see `rebuildBinaries.swift`. It's also a Swift script,
/// but does not depend on these helpers. Used as is it compiles the module into a `bin` folder and simply names