[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7054":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":16,"starSnapshotCount":16,"syncStatus":29,"lastSyncTime":30,"discoverSource":31},7054,"swift-format","swiftlang\u002Fswift-format","swiftlang","Formatting technology for Swift source code","",null,"Swift",2934,263,133,124,0,1,7,23,6,29.26,"Apache License 2.0",false,"main",[],"2026-06-12 02:01:33","# swift-format\n\n`swift-format` provides the formatting technology for\n[SourceKit-LSP](https:\u002F\u002Fgithub.com\u002Fswiftlang\u002Fsourcekit-lsp) and the building\nblocks for doing code formatting transformations.\n\nThis package can be used as a [command line tool](#command-line-usage)\nor linked into other applications as a Swift Package Manager dependency and\ninvoked via an [API](#api-usage).\n\n> NOTE: No default Swift code style guidelines have yet been proposed. The\n> style that is currently applied by `swift-format` is just one possibility,\n> and the code is provided so that it can be tested on real-world code and\n> experiments can be made by modifying it.\n\n## Matching swift-format to Your Swift Version\n\n### Swift 5.8 and later\n\nAs of Swift 5.8, swift-format depends on the version of\n[SwiftSyntax](https:\u002F\u002Fgithub.com\u002Fswiftlang\u002Fswift-syntax) whose parser has been\nrewritten in Swift and no longer has dependencies on libraries in the\nSwift toolchain.\n\nThis change allows `swift-format` to be built, developed, and run using\nany version of Swift that can compile it, decoupling it from the version\nthat supported a particular syntax. However, earlier versions of swift-format\nwill still not be able to recognize new syntax added in later versions of the\nlanguage and parser.\n\nNote also that the version numbering scheme has changed to match\nSwiftSyntax; the 5.8 release of swift-format is `508.0.0`, not `0.50800.0`.\n\n### Swift 5.7 and earlier\n\n`swift-format` versions 0.50700.0 and earlier depend on versions of\n[SwiftSyntax](https:\u002F\u002Fgithub.com\u002Fswiftlang\u002Fswift-syntax) that used a standalone\nparsing library distributed as part of the Swift toolchain. When using these\nversions, you should check out and build `swift-format` from the release\ntag or branch that is compatible with the version of Swift you are using.\n\nThe major and minor version components of `swift-format` and SwiftSyntax must\nbe the same—this is expressed in the `SwiftSyntax` dependency in\n[Package.swift](Package.swift)—and those version components must match the\nSwift toolchain that is installed and used to build and run the formatter:\n\n| Xcode Release   | Swift Version          | `swift-format` Branch \u002F Tags     |\n|:----------------|:-----------------------|:---------------------------------|\n| –               | Swift at `main`        | `main`                           |\n| Xcode 14.0      | Swift 5.7              | `release\u002F5.7` \u002F `0.50700.x`      |\n| Xcode 13.3      | Swift 5.6              | `release\u002F5.6` \u002F `0.50600.x`      |\n| Xcode 13.0–13.2 | Swift 5.5              | `swift-5.5-branch` \u002F `0.50500.x` |\n| Xcode 12.5      | Swift 5.4              | `swift-5.4-branch` \u002F `0.50400.x` |\n| Xcode 12.0–12.4 | Swift 5.3              | `swift-5.3-branch` \u002F `0.50300.x` |\n| Xcode 11.4–11.7 | Swift 5.2              | `swift-5.2-branch` \u002F `0.50200.x` |\n| Xcode 11.0–11.3 | Swift 5.1              | `swift-5.1-branch`               |\n\nFor example, if you are using Xcode 13.3 (Swift 5.6), you will need\n`swift-format` 0.50600.0.\n\n## Getting swift-format\n\nIf you are mainly interested in using swift-format (rather than developing it),\nthen you can get it in three different ways:\n\n### Included in the Swift Toolchain\n\nSwift 6 (included with Xcode 16) and above include swift-format in the toolchain. You can run `swift-format` from anywhere on the system using `swift format` (notice the space instead of dash). To find the path at which `swift-format` is installed in Xcode, run `xcrun --find swift-format`.\n\n### Installing via Homebrew\n\nRun `brew install swift-format` to install the latest version.\n\n### Building from source\n\nInstall `swift-format` using the following commands:\n\n```sh\nVERSION=510.1.0  # replace this with the version you need\ngit clone https:\u002F\u002Fgithub.com\u002Fswiftlang\u002Fswift-format.git\ncd swift-format\ngit checkout \"tags\u002F$VERSION\"\nswift build -c release\n```\n\nNote that the `git checkout` command above will leave the repository in a\n\"detached HEAD\" state. This is fine if building and running the tool is all you\nwant to do.\n\nOnce the build has finished, the `swift-format` executable will be located at\n`.build\u002Frelease\u002Fswift-format`.\n\nTo test that the formatter was built successfully and is compatible with your\nSwift toolchain, you can also run the following command:\n\n```sh\nswift test --parallel\n```\n\nWe recommend using the `--parallel` flag to speed up the test run since there\nare a large number of tests.\n\n## Command Line Usage\n\nThe general invocation syntax for `swift-format` is as follows:\n\n```sh\nswift-format [SUBCOMMAND] [OPTIONS...] [FILES...]\n```\n\nThe tool supports a number of subcommands, each of which has its own options\nand are described below. Descriptions of the subcommands that are available\ncan also be obtained by running `swift-format --help`, and the description of\na specific subcommand can be obtained by using the `--help` flag after the\nsubcommand name; for example, `swift-format lint --help`.\n\n### Formatting\n\n```sh\nswift-format [format] [OPTIONS...] [FILES...]\n```\n\nThe `format` subcommand formats one or more Swift source files (or source code\nfrom standard input if no file paths are given on the command line). Writing\nout the `format` subcommand is optional; it is the default behavior if no other\nsubcommand is given.\n\nThis subcommand supports all of the\n[common lint and format options](#options-supported-by-formatting-and-linting),\nas well as the formatting-only options below:\n\n*   `-i\u002F--in-place`: Overwrites the input files when formatting instead of\n    printing the results to standard output. _No backup of the original file is\n    made before it is overwritten._\n\n### Linting\n\n```sh\nswift-format lint [OPTIONS...] [FILES...]\n```\n\nThe `lint` subcommand checks one or more Swift source files (or source code\nfrom standard input if no file paths are given on the command line) for style\nviolations and prints diagnostics to standard error for any violations that\nare detected.\n\nThis subcommand supports all of the\n[common lint and format options](#options-supported-by-formatting-and-linting),\nas well as the linting-only options below:\n\n*   `-s\u002F--strict`: If this option is specified, lint warnings will cause the\n    tool to exit with a non-zero exit code (failure). By default, lint warnings\n    do not prevent a successful exit; only fatal errors (for example, trying to\n    lint a file that does not exist) cause the tool to exit unsuccessfully.\n\n### Options Supported by Formatting and Linting\n\nThe following options are supported by both the `format` and `lint`\nsubcommands:\n\n*   `--assume-filename \u003Cpath>`: The file path that should be used in\n    diagnostics when linting or formatting from standard input. If this option\n    is not provided, then `\u003Cstdin>` will be used as the filename printed in\n    diagnostics.\n\n*   `--color-diagnostics\u002F--no-color-diagnostics`: By default, `swift-format`\n    will print diagnostics in color if standard error is connected to a\n    terminal and without color otherwise (for example, if standard error is\n    being redirected to a file). These flags can be used to force colors on\n    or off respectively, regardless of whether the output is going to a\n    terminal.\n\n*   `--configuration \u003Cfile>`: The path to a JSON file that contains\n    [configurable settings](#configuring-the-command-line-tool) for\n    `swift-format`. If omitted, a default configuration is use (which\n    can be seen by running `swift-format dump-configuration`).\n\n*   `--ignore-unparsable-files`: If this option is specified and a source file\n    contains syntax errors or can otherwise not be parsed successfully by the\n    Swift syntax parser, it will be ignored (no diagnostics will be emitted\n    and it will not be formatted). Without this option, an error will be\n    emitted for any unparsable files.\n\n*   `-p\u002F--parallel`: Process files in parallel, simultaneously across\n    multiple cores.\n\n*   `-r\u002F--recursive`: If specified, then the tool will process `.swift` source\n    files in any directories listed on the command line and their descendants.\n    Without this flag, it is an error to list a directory on the command line.\n\n### Viewing the Default Configuration\n\n```sh\nswift-format dump-configuration\n```\n\nThe `dump-configuration` subcommand dumps the default configuration in JSON\nformat to standard output. This can be used to simplify generating a custom\nconfiguration, by redirecting it to a file and editing it.\n\n### Configuring the Command Line Tool\n\nFor any source file being checked or formatted, `swift-format` looks for a\nJSON-formatted file named `.swift-format` in the same directory. If one is\nfound, then that file is loaded to determine the tool's configuration. If the\nfile is not found, then it looks in the parent directory, and so on.\n\nIf no configuration file is found, a default configuration is used. The\nsettings in the default configuration can be viewed by running\n`swift-format dump-configuration`, which will dump it to standard\noutput.\n\nIf the `--configuration \u003Cconfiguration>` option is passed to `swift-format`,\nthen that configuration will be used unconditionally and the file system will\nnot be searched.\n\nSee [Documentation\u002FConfiguration.md](Documentation\u002FConfiguration.md) for a\ndescription of the configuration format and the settings that are available.\n\n#### Viewing the Effective Configuration\n\nThe `dump-configuration` subcommand accepts a `--effective` flag. If set, it\ndumps the configuration that would be used if `swift-format` was executed from\nthe current working directory, and accounts for `.swift-format` files or\n `--configuration` options as outlined above.\n\n### Miscellaneous\n\nRunning `swift-format -v` or `swift-format --version` will print version\ninformation about `swift-format` version and then exit.\n\n## API Usage\n\n`swift-format` can be easily integrated into other tools written in Swift.\nInstead of invoking the formatter by spawning a subprocess, users can depend on\n`swift-format` as a Swift Package Manager dependency and import the\n`SwiftFormat` module, which contains the entry points into the formatter's\ndiagnostic and correction behavior.\n\nFormatting behavior is provided by the `SwiftFormatter` class and linting\nbehavior is provided by the `SwiftLinter` class. These APIs can be passed\neither a Swift source file `URL` or a `Syntax` node representing a\nSwiftSyntax syntax tree. The latter capability is particularly useful for\nwriting code generators, since it significantly reduces the amount of trivia\nthat the generator needs to be concerned about adding to the syntax nodes it\ncreates. Instead, it can pass the in-memory syntax tree to the `SwiftFormat`\nAPI and receive perfectly formatted code as output.\n\nPlease see the documentation in the\n[`SwiftFormatter`](Sources\u002FSwiftFormat\u002FAPI\u002FSwiftFormatter.swift) and\n[`SwiftLinter`](Sources\u002FSwiftFormat\u002FAPI\u002FSwiftLinter.swift) classes for more\ninformation about their usage.\n\n### Checking Out the Source Code for Development\n\nThe `main` branch is used for development. Pull requests should be created\nto merge into the `main` branch; changes that are low-risk and compatible with\nthe latest release branch may be cherry-picked into that branch after they have\nbeen merged into `main`.\n\nIf you are interested in developing `swift-format`, there is additional\ndocumentation about that [here](Documentation\u002FDevelopment.md).\n\n## Contributing\n\nContributions to Swift are welcomed and encouraged! Please see the\n[Contributing to Swift guide](https:\u002F\u002Fswift.org\u002Fcontributing\u002F).\n\nBefore submitting the pull request, please make sure you have [tested your\n changes](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift\u002Fblob\u002Fmain\u002Fdocs\u002FContinuousIntegration.md)\n and that they follow the Swift project [guidelines for contributing\n code](https:\u002F\u002Fswift.org\u002Fcontributing\u002F#contributing-code).\n\nTo be a truly great community, [Swift.org](https:\u002F\u002Fswift.org\u002F) needs to welcome\ndevelopers from all walks of life, with different backgrounds, and with a wide\nrange of experience. A diverse and friendly community will have more great\nideas, more unique perspectives, and produce more great code. We will work\ndiligently to make the Swift community welcoming to everyone.\n\nTo give clarity of what is expected of our members, Swift has adopted the\ncode of conduct defined by the Contributor Covenant. This document is used\nacross many open source communities, and we think it articulates our values\nwell. For more, see the [Code of Conduct](https:\u002F\u002Fswift.org\u002Fcode-of-conduct\u002F).\n","`swift-format` 是一个用于格式化 Swift 源代码的工具。其核心功能包括提供给 SourceKit-LSP 的格式化技术支持以及作为构建代码格式转换的基础组件。该工具既可以通过命令行直接使用，也可以作为 Swift 包依赖集成到其他应用程序中，并通过 API 调用。适用于需要统一或调整 Swift 代码风格的各种开发场景，特别是当团队希望提高代码可读性和一致性时。需要注意的是，目前 `swift-format` 应用的代码风格仅是一种可能性，并非官方推荐的标准。此外，从 Swift 5.8 版本开始，`swift-format` 对 SwiftSyntax 的依赖进行了更新，使其能够独立于特定版本的 Swift 语法运行。",2,"2026-06-11 03:10:18","top_language"]