The ordering has a few choices a project makes in .swiftstepdown.json, which
SwiftStepdown reads from the current directory or the nearest folder above it; with none, private helpers
move below their last caller, within their // MARK: section. Every key is optional:
{
"moves": "internal",
"sharedHelpers": "first",
"sections": "merge",
"exclude": ["Sources/Generated", "**/*.pb.swift"]
}| Key | Does |
|---|---|
moves |
the widest access that moves: private (the default, with fileprivate), internal (with package), or public (everything) |
sharedHelpers |
where a helper several declarations use goes: below the last of them (the default), or the first |
sections |
whether // MARK: sections hold their declarations: keep (the default) or merge |
exclude |
paths left as they are, from the folder holding .swiftstepdown.json: *, **, ?, or a folder for all of it |
A key or value SwiftStepdown doesn't know stops the run, so a typo can't quietly leave the default in place.
--style <file> reads a style from elsewhere (Usage); its exclude paths start from the
folder that file is in.
private is the conservative choice: a type's API keeps the order its author gave it, and only the
helpers behind it move. internal suits app code, where most declarations are internal and the
distinction between API and helper is looser. public applies the stepdown rule to everything, which reads
well but reorders the most, so it is worth a look at the diff first.
SwiftFormat's organizeDeclarations rule sorts members by kind and access, and would move helpers back
below every public declaration. Run one or the other on the same files, or turn that rule off with
--disable organizeDeclarations. SwiftLint's type_contents_order checks a similar order, and conflicts
the same way.