add SwiftLint to Xcode workspace
Asked on 2024-07-30
1 search
To add SwiftLint to your Xcode workspace, you can follow these general steps:
-
Install SwiftLint: You can install SwiftLint using Homebrew by running the following command in your terminal:
brew install swiftlint
-
Add a Run Script Phase: In your Xcode project, navigate to your target's build phases and add a new "Run Script Phase". You can do this by clicking the "+" button in the top left corner of the build phases tab.
-
Configure the Run Script: In the new run script phase, add the following script to run SwiftLint:
if which swiftlint >/dev/null; then swiftlint else echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" fi
-
Customize SwiftLint: Optionally, you can customize SwiftLint by creating a
.swiftlint.yml
file in the root of your project. This file allows you to configure rules, exclude files, and more.
For more detailed information on custom scripts in Xcode, you can refer to the session Extend your Xcode Cloud workflows at WWDC 2024, which discusses how to define custom scripts inside your repository that will be run at specific points in your build process.
Relevant Sessions

Platforms State of the Union
Discover the newest advancements on Apple platforms.

Migrate your app to Swift 6
Experience Swift 6 migration in action as we update an existing sample app. Learn how to migrate incrementally, module by module, and how the compiler helps you identify code that’s at risk of data races. Discover different techniques for ensuring clear isolation boundaries and eliminating concurrent access to shared mutable state.

Go small with Embedded Swift
Embedded Swift brings the safety and expressivity of Swift to constrained environments. Explore how Embedded Swift runs on a variety of microcontrollers through a demonstration using an off-the-shelf Matter device. Learn how the Embedded Swift subset packs the benefits of Swift into a tiny footprint with no runtime, and discover plenty of resources to start your own Embedded Swift adventure.