← All work

Open source · Swift CLI

init-revise-cli

A Swift CLI that asks SourceKit for the type behind .init shorthand, then writes it explicitly.

Example.swift
Before
doSomething(
  model: .init(value: "1")
)

models = [
  .init(value: "2"),
  .init(value: "3")
]
After
doSomething(
  model: Test.ViewModel(value: "1")
)

models = [
  Test.ViewModel(value: "2"),
  Test.ViewModel(value: "3")
]
SourceKit resolves each type, then SwiftSyntax updates the source without touching the surrounding code.

Making inferred initializers explicit

In a complex Swift expression, .init(...) leaves the compiler to work out the type from context. init-revise-cli asks SourceKit for the resolved type and writes the fully qualified initializer back into the file.

SwiftSyntax handles the edit and preserves the surrounding code. The tool supports optionals, arrays, nested types, and whole Xcode projects using per-file compiler arguments.

Type
Command-line tool
Focus
Source rewriting
Stack
SourceKit · SwiftSyntax