# Linting a Swift package with swift-format

DevFeed: [Linting a Swift package with swift-format](<https://devfeed.tech/articles/linting-a-swift-package-with-swift-format-24550.md>)

Original publisher: [Read original article](<https://medium.com/snapp-mobile/linting-a-swift-package-with-swift-format-a887b4e95a1e?source=rss----bcd96e620b02---4>)

Author: Oleksii Kolomiiets

Published: 2025-01-27T08:59:47Z

Content type: tutorial

Language: en

Sources: [Snapp Mobile - Medium](<https://devfeed.tech/sources/snapp-mobile-medium.md>)

Topics: [Swift](<https://devfeed.tech/topics/swift.md>), [Xcode 16](<https://devfeed.tech/topics/xcode-16.md>), [developer tooling](<https://devfeed.tech/topics/developer-tooling.md>), [Development](<https://devfeed.tech/topics/development.md>)

Tags: [build](<https://devfeed.tech/tags/build.md>), [development-tools](<https://devfeed.tech/tags/development-tools.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [ios](<https://devfeed.tech/tags/ios.md>), [lint](<https://devfeed.tech/tags/lint.md>), [packages](<https://devfeed.tech/tags/packages.md>), [plugin](<https://devfeed.tech/tags/plugin.md>), [swift](<https://devfeed.tech/tags/swift.md>), [swift-package-manager](<https://devfeed.tech/tags/swift-package-manager.md>), [xcode-16](<https://devfeed.tech/tags/xcode-16.md>)

## AI overview

This tutorial explains how to enable linting for a Swift package during its build process with the built-in swift-format tool included in the Xcode 16 toolchain. It covers creating a package, adding a package plugin, attaching the plugin to targets, and displaying a test warning during the build.

## Source excerpt

Linting your code is handy and effective way to keep your team's code style in shape. Nowadays it's hard to imagine a project without functionality that alerts developers with warnings or errors about issues in the code. It could be done with a simple script added to build phases. But what can you do when you don't have one? Packages are excluded from this option, but they still need to be maintained. Or at the very least, you'll feel much better knowing your package code is clean and consistent, and no one can make it messy without receiving a warning. This article explains how to enable linting for a package during its build process, using only the built-in swift-format tool -- no external libraries required. Preparation With Xcode 16, swift-format is included as part of the Xcode toolchain, eliminating the need for external libraries and making Swift file formatting more convenient. For more information, refer to the Getting swift-format section. 1. Create a package Launch Xcode and select File > New > Package from the menu. Chose Library and add the name to the package. 2. Add Plugin Package plugin is: Swift script that can be run as part of your buildA package could have plugins as extra, or be all about pluginsPackage plugins are available only within packageGeneral plugins can be made available to the outsideLets you access development tools on your machine More information about package plugins can be found in the Meet Swift Package plugins article. Start by creating a dedicated folder for all potential plugins, including the one you're currently working on. Ctrl + click on your package name in Xcode and select "New Folder" or use any other method to create a folder in the root of your project. Next, create a folder specifically for your plugin's logic. Since it will lint the package code using swift-format , the name SwiftFormatPlugin was chosen. By the end, the structure would look like this Now, let's add some content to plugin file import Foundation impor