How to configure Build Scripts in Xcode

This document provides step-by-step instructions on how to configure a build script to run on each build executing a command line tool. SwiftLint is used as an example.

Cihat Gündüz
2 min readFeb 11, 2019


Step 1: First, install the tool(s) you want to execute in the build script (e.g. via Homebrew or Mint)

brew install swiftlint

Step 2: In Xcode, select your target to add the build script to

Step3: Navigate to the Build Phases tab

Step 4: Click the + Button and choose New Run Script Phase

Step 5: Rename your new script by double-clicking onto the text Run Script

Step 6: Copy the following script into the text field below Shell: /bin/sh

Xcode destroys any indentation when copying scripts. Just reindent manually.

Step 7 (optional):
Drag & Drop your build script to specify in which order it should be run.

Now just build your target (Cmd+B) to see that it works.

Note that the script will make sure the tool is only executed if it is installed. Other developers working on the project who don’t have the tool installed will see an Xcode warning stating:

SwiftGen not installed, download it from

That’s it, happy coding!

💁🏻‍♂️ Enjoyed this article? Check out my app RemafoX!
A native Mac app that integrates with Xcode to help translate your app.
Get it now to save time during development & make localization easy.

👨🏻‍💻 Want to Connect?
Follow me on 👾 Twitch, 🎬 YouTube, 🐦 Twitter, and 🦣 Mastodon.



Cihat Gündüz

📱Indie iOS Developer, 🎬Content Creator for 👨🏻‍💻Developers. Apps: RemafoX, Twoot it!. More in the works.