Does Xcode have an internal swift-format config file?

swift-format uses 2-space indentation by default. But when invoked from Xcode, it uses 4-space indentation. I wonder why it's so? Does Xcode have an internal swift-format config file? But I can't find it. I ask about this because I want to change other settings (e.g. line length). It would be convenient if I could change them in a single place rather than in every Swift packages and projects.

Yes, that's possible.

Thanks. I knew that, but it requires to put .swift-format in each swift package. That is inconvenient if my project contains many swift packages. Take git config file for example, it can be placed at system level, user level, or repository level. What I'm looking for is a user level swift-format config file or one that's used internally by Xcode.

Swift format works by looking the file recursively up the file hierarchy until it finds one, so you could place it high enough so that it's visible, e.g. if you place it in the /Users folder it will be visible for all users and if you place it into ~ it will be visible to all project for the current user - unless it is overridden by another file down the file hierarchy.

2 Likes