ITADN

how do i pin the version of swift in my project?

#517OpenDetachHead 创建于 2026-03-28
D
DetachHeadcommented
i tried using `.swift-version` but in my CI on macOS it seems to just completely ignore it and change it to the latest version? # `.github/workflows/ci.yaml` ```yaml jobs: build-macos: runs-on: "macos-latest" steps: - uses: actions/checkout@v4 - run: | brew install swiftly swiftly init . "/Users/runner/.swiftly/env.sh" swift build ``` # `.swift-version` ``` 6.2.4 ``` # `Package.swift` ```swift // swift-tools-version: 6.2.4 // ... ``` # github actions output ``` ==> Fetching downloads for: swiftly ✔︎ Bottle Manifest swiftly (1.1.1) ✔︎ Bottle swiftly (1.1.1) ==> Pouring swiftly--1.1.1.arm64_sequoia.bottle.1.tar.gz 🍺 /opt/homebrew/Cellar/swiftly/1.1.1: 10 files, 26.5MB ==> Caveats Bash completion has been installed to: /opt/homebrew/etc/bash_completion.d Welcome to swiftly, the Swift toolchain manager for Linux and macOS! Please read the following information carefully before proceeding with the installation. If you wish to customize the steps performed during the installation process, refer to 'swiftly init -h' for configuration options. Swiftly installs files into the following locations: /Users/runner/.swiftly - Directory for configuration files /Users/runner/.swiftly/bin - Links to the binaries of the active toolchain /Users/runner/Library/Developer/Toolchains - Directory hosting installed toolchains These locations can be changed by setting the environment variables SWIFTLY_HOME_DIR, SWIFTLY_BIN_DIR, and SWIFTLY_TOOLCHAINS_DIR before running 'swiftly init' again. Once swiftly is set up, it will install the latest available Swift toolchain. This can be suppressed with the '--skip-install' option. For your convenience, swiftly will also attempt to modify your shell's profile file to make installed items available in your environment upon login. This can be suppressed with the '--no-modify-profile' option. Proceed? (Y/n): Creating shell environment file for the user... Updating profile... Fetching the latest stable Swift release... Installing Swift 6.3.0 Downloading Swift 6.3.0 0%: Downloaded 0.7 MiB of 1433.3 MiB 1%: Downloaded 17.2 MiB of 1433.3 MiB 2%: Downloaded 39.7 MiB of 1433.3 MiB 4%: Downloaded 63.6 MiB of 1433.3 MiB 6%: Downloaded 87.4 MiB of 1433.3 MiB 7%: Downloaded 111.1 MiB of 1433.3 MiB 9%: Downloaded 134.5 MiB of 1433.3 MiB 11%: Downloaded 157.8 MiB of 1433.3 MiB 12%: Downloaded 180.8 MiB of 1433.3 MiB 14%: Downloaded 204.3 MiB of 1433.3 MiB 15%: Downloaded 227.5 MiB of 1433.3 MiB 17%: Downloaded 251.1 MiB of 1433.3 MiB 19%: Downloaded 274.6 MiB of 1433.3 MiB 20%: Downloaded 298.0 MiB of 1433.3 MiB 22%: Downloaded 321.4 MiB of 1433.3 MiB 24%: Downloaded 344.6 MiB of 1433.3 MiB 25%: Downloaded 367.9 MiB of 1433.3 MiB 27%: Downloaded 391.7 MiB of 1433.3 MiB 28%: Downloaded 415.0 MiB of 1433.3 MiB 32%: Downloaded 461.1 MiB of 1433.3 MiB 33%: Downloaded 484.3 MiB of 1433.3 MiB 35%: Downloaded 507.7 MiB of 1433.3 MiB 37%: Downloaded 531.0 MiB of 1433.3 MiB 38%: Downloaded 554.6 MiB of 1433.3 MiB 40%: Downloaded 577.6 MiB of 1433.3 MiB 41%: Downloaded 600.3 MiB of 1433.3 MiB 43%: Downloaded 623.5 MiB of 1433.3 MiB 45%: Downloaded 646.9 MiB of 1433.3 MiB 46%: Downloaded 670.1 MiB of 1433.3 MiB 48%: Downloaded 693.3 MiB of 1433.3 MiB 49%: Downloaded 716.6 MiB of 1433.3 MiB 51%: Downloaded 739.9 MiB of 1433.3 MiB 53%: Downloaded 762.4 MiB of 1433.3 MiB 54%: Downloaded 786.1 MiB of 1433.3 MiB 56%: Downloaded 809.5 MiB of 1433.3 MiB 58%: Downloaded 833.2 MiB of 1433.3 MiB 59%: Downloaded 856.0 MiB of 1433.3 MiB 61%: Downloaded 879.0 MiB of 1433.3 MiB 62%: Downloaded 902.1 MiB of 1433.3 MiB 64%: Downloaded 925.0 MiB of 1433.3 MiB 66%: Downloaded 948.3 MiB of 1433.3 MiB 67%: Downloaded 971.1 MiB of 1433.3 MiB 69%: Downloaded 994.3 MiB of 1433.3 MiB 70%: Downloaded 1017.6 MiB of 1433.3 MiB 72%: Downloaded 1040.4 MiB of 1433.3 MiB 74%: Downloaded 1063.6 MiB of 1433.3 MiB 75%: Downloaded 1086.8 MiB of 1433.3 MiB 77%: Downloaded 1109.8 MiB of 1433.3 MiB 79%: Downloaded 1133.0 MiB of 1433.3 MiB 80%: Downloaded 1156.7 MiB of 1433.3 MiB 82%: Downloaded 1180.2 MiB of 1433.3 MiB 83%: Downloaded 1203.1 MiB of 1433.3 MiB 85%: Downloaded 1226.5 MiB of 1433.3 MiB 87%: Downloaded 1249.8 MiB of 1433.3 MiB 88%: Downloaded 1273.1 MiB of 1433.3 MiB 90%: Downloaded 1296.5 MiB of 1433.3 MiB 92%: Downloaded 1319.6 MiB of 1433.3 MiB 93%: Downloaded 1342.9 MiB of 1433.3 MiB 95%: Downloaded 1366.2 MiB of 1433.3 MiB 96%: Downloaded 1389.8 MiB of 1433.3 MiB 98%: Downloaded 1413.3 MiB of 1433.3 MiB 100%: Downloaded 1433.3 MiB of 1433.3 MiB Installing package in user home directory... The file `/Users/runner/work/project/project/.swift-version` has been set to `Swift 6.3.0` The global default toolchain has been set to `Swift 6.3.0` Swift 6.3.0 is installed successfully! To begin using installed swiftly from your current shell, first run the following command: # Added by swiftly . "/Users/runner/.swiftly/env.sh" NOTE: Swiftly has updated some elements in your path and your shell may not yet be aware of the changes. You can update your shell's environment by running hash -r or restarting your shell. ``` i don't understand why it would change the `.swift-version` automatically. that seems to defeat the purpose of the `.swift-version` file
0 条评论