Linting your Xcode projects with xclint
In this post I'll talk about a tool that I have recently released xclint, which validates the structure of your Xcode projects, offering insightful warnings about things that might be wrong in the project structure.
Xcode projects are hard to work with, especially when there is a team behind using git. It's straightforward to mess things up and end up with a project, which Xcode might be able to read and compile, but that internally is not in a good state:
- There are entries that are duplicated (a common issue when solving git conflicts in the project file).
- There are elements that refer to others that don't exist anymore.
- There are attributes that are missing.
- Some file references point to files that don't exist anymore.
Keeping Xcode projects in a healthy state is very important and unfortunately, there was no tool that helped you validate that. CocoaPods for instance throws a warning when you do
pod install, if there are multiple elements with the same identifier.
Since xcproj, opened an API to read any Xcode project, I decided to leverage it to build a command line tool, xclint that we could use to validate the state of our Xcode projects.
Install & Usage
You can install the tool using Homebrew:
brew tap xcodeswift/xclint [email protected]:xcodeswift/xclint.git brew install xclint
Or run it using Mint 🌱:
mint install xcodeswift/xclint
Its usage is very simple, you just need to pass one parameter, which is the Xcode project that you want to validate:
The screenshot below shows an example of the tool output when there are validation errors:
The tool currently supports validation of missing references, and attributes that there are things that we'd like to support in future editions:
- Detect multiple elements with the same reference.
- Spot files that are referred from the project that are missing.
Moreover, we plan to support CocoaPods, so that you could install the tool using CocoaPods and use the binary from a project build phase.
It's the first version of the tool,
0.1.0 so it's very likely that you encounter some errors. If so, don't hesitate to open issues on GitHub with all sort of issues that you found using the tool. Moreover, if you have any idea of things that we could validate or features that we could add to the tool, feel free to open issues or pull requests with your proposals. You're very welcome!