swiftlang / swift-format

Formatting technology for Swift source code
Apache License 2.0
2.46k stars 225 forks source link

readme: Clarify where to place configuration file so Xcode automatically uses that config #809

Open mesqueeb opened 2 hours ago

mesqueeb commented 2 hours ago

Executing swift format dump-configuration on macOS 15 shows the default Swift format rules.

I'd like to save this JSON somewhere in my project, so that Xcode automatically uses those rules when tapping Format File with 'swift-format' in Xcode 16.

Committing the rules config json to the project, would make the entire team use the same rules as well.

Can we add a section on the README that explains this? I believe any project that has more than 1 person working on it needs this. :tada:

ahoppen commented 2 hours ago

Synced to Apple’s issue tracker as rdar://136327486

mesqueeb commented 2 hours ago

as per these docs: https://github.com/swiftlang/swift-format/blob/main/Documentation/Configuration.md#example I have added a .swift-format file with the following contents to my Xcode workspace root:

{
  "version": 1,
  "lineLength": 120,
  "indentation": {
    "spaces": 2
  },
  "maximumBlankLines": 1
}

but executing Format File with 'swift-format' will not use this configuration. 🤔