A tool to help you migrate your Swift code to new any
and some
keywords.
- Download the release on Github
- Run
// From a bash script
migrator ./your/path/folder
--ignoreFolders "FooFolder, BarFolder" \
--policy strict \
--conservative
// From yout terminal
./migrator ./your/path/folder --conservative
SwiftSomeAnyMigrator will found all the Swift files recursively for a given path and will add some
or any
based on your policy.
You can use --policy strict
or --policy light
.
light
use any
everywhere while strict
will try to introduce some
keywords whenever think it's possible.
Example:
Using strict
mode (more optimized but less chance to compile out of the box)
// Before
init(
a: FooProtocol = Foo(),
b: FooProtocol = FooSingleton.shared
)
func foo(FooProtocol){}
// After
init(
a: some FooProtocol = Foo(),
b: any FooProtocol = FooSingleton.shared
)
func foo(some FooProtocol){}
Using light
mode (more chance to compile but less optimized)
// Before
init(
a: FooProtocol = Foo(),
b: FooProtocol = FooSingleton.shared
)
func foo(FooProtocol){}
// After
init(
a: any FooProtocol = Foo(),
b: any FooProtocol = FooSingleton.shared
)
func foo(any FooProtocol){}
If you add --conservative
flag, the tool will keep pre-existing any
or some
keyword encountered in your codebase.
SwiftSomeAnyMigrator is only making static analysis, he could not understand what is really injected and can only make syntax guess. Because of this, his guess could be wrong sometimes. It does NOT mean you should always use light
mode. SwiftSomeAnyMigrator is an helper tool to cover a maximum of cases, resulting to the developer to only arbitrate a bunch of cases after the tool have runned instead of the whole codebase.
SwiftSomeAnyMigrator uses SwiftConcurrency behind the hood to apply changes concurrently and faster to your codebase.
~3 sec. / 1k files.