From e96839166da8330de5bc0c317bce58c8128b91ce Mon Sep 17 00:00:00 2001 From: Adam Fisher Date: Tue, 4 Aug 2026 14:21:56 +0000 Subject: [PATCH] Adopt .tool-versions and scripts-to-rule-them-all for swift Pins swift 6 in .tool-versions. Adds script/setup (PATH check, swift package resolve), script/test (swift test) and script/start (swift run). Rewrites the README to the standard Prerequisites/Usage/Structure template, replacing the homebrew and XCode instructions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- swift/.tool-versions | 1 + swift/README.md | 34 ++++++++++++++++++++-------------- swift/script/setup | 7 +++++++ swift/script/start | 7 +++++++ swift/script/test | 7 +++++++ 5 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 swift/.tool-versions create mode 100755 swift/script/setup create mode 100755 swift/script/start create mode 100755 swift/script/test diff --git a/swift/.tool-versions b/swift/.tool-versions new file mode 100644 index 0000000..61f5544 --- /dev/null +++ b/swift/.tool-versions @@ -0,0 +1 @@ +swift 6 diff --git a/swift/README.md b/swift/README.md index 78ea463..cedecbc 100644 --- a/swift/README.md +++ b/swift/README.md @@ -2,22 +2,28 @@ Skeleton project for Swift. -## Usage -- Follow instructions at https://www.swift.org/install/ to install the Swift SDK -- `swift test` to run the tests -- `swift run` to run the code +## Prerequisites -## Structure -- Tests located in [`CodingExerciseTests.swift`](./Tests/CodingExerciseTests/CodingExerciseTests.swift) -- Runtime code located in [`CodingExercise.swift`](./Sources/CodingExercise/CodingExercise.swift) +The toolchain this project needs is declared in [`.tool-versions`](./.tool-versions): + +``` +swift 6 +``` -However, feel free to organise your code as you like. +Install those however you prefer, as long as they end up on your `PATH`. The quickest route is +[mise](https://mise.jdx.dev/), which reads the file for you: -## IDE +```sh +mise install +``` -The pairing test is a generic problem solving exercise and you can use any code editor you like so long as you can run swift code and write unit tests. +## Usage +- `./script/setup` to resolve dependencies +- `./script/test` to run the tests +- `./script/start` to run the app + +## Structure +- Tests located in [`CodingExerciseTests.swift`](./Tests/CodingExerciseTests/CodingExerciseTests.swift) +- Code located in [`CodingExercise.swift`](./Sources/CodingExercise/CodingExercise.swift) -However we suggest any of the following as they're the easiest to get started with: -- [XCode](https://developer.apple.com/xcode/) -- [VSCode](https://code.visualstudio.com/) or [VSCodium](https://vscodium.com/) with the [Swift extension](https://marketplace.visualstudio.com/items?itemName=swiftlang.swift-vscode) -- [XCode Swift Playground](https://www.apple.com/uk/swift/playgrounds/) \ No newline at end of file +However, you're free to organise your code as you like. \ No newline at end of file diff --git a/swift/script/setup b/swift/script/setup new file mode 100755 index 0000000..0b980ee --- /dev/null +++ b/swift/script/setup @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +swift package resolve diff --git a/swift/script/start b/swift/script/start new file mode 100755 index 0000000..8e37626 --- /dev/null +++ b/swift/script/start @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +swift run diff --git a/swift/script/test b/swift/script/test new file mode 100755 index 0000000..c9a1f5a --- /dev/null +++ b/swift/script/test @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +swift test