Hello Everyone, Welcome to my blog on how to format swift code using swiftformat & swiftlint.
TOOLS USAGE
$ brew install swiftformat
$ swiftformat [fileName]
$ brew install swiftlint
$ swiftLint [fileName]
INTEGRATE XCODE
Integrate SwiftLint into your Xcode project to get warnings and errors displayed in the issue navigator.
To do this click the Project in the file navigator, then click the primary app target, and go to Build Phases. Click the + and select "New Run Script Phase". Insert the following as the script:
Similarly, create the build phase with Swiftformat.
ISSUES RELATED TO SOURCE CODE
Issues found during the lint format:
Tool to run from command line
$ swift run ModernSSG | swiftformat .
Other IDE Integrations
- AppCode
To integrate SwiftLint with AppCode, install
this plugin and configure
SwiftLint's installed path in the plugin's preferences.
The autocorrect
action is available via β₯β
.
2.Atom
To integrate SwiftLint with Atom, install the
linter-swiftlint
package from
APM.
- Visual Studio Code
To integrate SwiftLint with vscode, install the
vscode-swiftlint
extension from the marketplace.
Conclusion
This source code format in swift is easy and prominent for the development process and makes code less prone to small errors. This development will surely reduce the issues and make a constant format for new projects.
Top comments (1)
Thanks a lot bro βΊοΈπ