Pedro Piñera bio photo

Pedro Piñera

Mobile Engineer and Open-Source ♥



SpeakerDeck Medium Email Twitter Facebook Google+ Github Stackoverflow

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 git@github.com: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:

xclint MyProject.xcodeproj

The screenshot below shows an example of the tool output when there are validation errors:

xclint output when there are warnings

What’s next

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.

Feedback

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!

xcode.swift
xcode.swift is an open source organization that aims to build libraries and tools in Swift to make working with Xcode easier and a more pleasant experience. All the tools are built in the open and support multiple dependency management tools like Swift Package Manager, CocoaPods or Carthage.

Check out other tools on the GitHub organization and stay up to date following the twitter account @xcodeswiftio. You are also welcome to join the organization Slack where you can talk to the contributors and other users of the tools.