4/25/2023 0 Comments Xcode format code![]() This will suggest a set of formatting options to use that match your existing project style (but you are free to ignore these and use the defaults, or your own settings if you prefer). (Optional) In Terminal, type swiftformat -inferoptions "/path/to/your/code/". ![]() Make sure that you have committed all your changes to that code safely in git (or whatever source control system you use). If you run it in your home directory, it will probably reformat every Swift file on your hard drive.Ĭhoose a file or directory that you want to apply the changes to. will overwrite any Swift files it finds in the current directory, and any subfolders therein. , you can instead type an absolute or relative path to the file or directory that you want to format. (that's a space and then a period after the command) in the terminal to format any Swift files in the current directory. If you followed the installation instructions above, you can now just type bash_profile file and run the command source ~/.bash_profile for the changes to take effect. Run swiftformat -help to see the available options). Open ~/.bash_profile in your favorite text editor (this is a hidden file, but you can type open ~/.bash_profile in the terminal to open it).Īdd the following line to the file: alias swiftformat="/usr/local/bin/swiftformat -indent 4" (you can omit the -indent 4, or replace it with something else. Open SwiftFormat.xcodeproj and build the SwiftFormat (Application) scheme.ĭrag the swiftformat binary into /usr/local/bin/ (this is a hidden folder, but you can use the Finder's Go > Go to Folder. If you would prefer not to use a package manager, you can build the command-line app manually: Assuming you already have Homebrew installed, just type: ![]() You can install the swiftformat command-line tool on macOS or Linux using Homebrew. NOTE: if you are using any of the following methods to install SwiftFormat on macOS 10.14.3 or earlier and are experiencing a crash on launch, you may need to install the Swift 5 Runtime Support for Command Line Tools.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |