Top 5 Command Line Tools for iOS Developer

Xcode comes with lot of command line tools which you can find at path

 each one has a specific purpose but some of them are very important in day to day role of iOS Developers. Most iOS Developers like to do everything from GUI either Xcode or using third party GUI tools but skilled and experienced developer uses command line tools like boss. There are some useful tools that every iOS developer should know and few of them are prefixed with “XC”. In this post, let’s go through five of them.

xcodebuild

The command  xcodebuild  is a father of all the commands in iOS development. You can do most of the iOS developer task like clean, analyse, build, test, archive with ‘xcodebuild’ command however you need to pass a lot of option to ‘xcodebuild’ to get the right things done. You can explore these options using its man page

Or you can find all these useful information in the web page here. We can use xcodebuild to build, test and archive our project targets or schemes. The example of the ‘xcodebuild’ would be

The ‘xcodebuild’ is huge command and mastering it takes a lot of time but once you know it then you can script anything related to iOS development.

xcode-select

Xcode has an active developer directory usually located at  /Applications/Xcode.app/Contents/Developer/  or we can set it with environmental DEVELOPER_DIR. The command xcode-select  is used to manage active developer directory of the Xcode so that we can manage two version of Xcode at the same time. We can switch between Xcode version e.g we want to use Xcode beta

$ sudo xcode-select --switch /Applications/Xcode-beta.app/

We can also use ‘xcode-select’ to install Xcode command line tools with GUI interaction using command

$ xcode-select --install

xcrun

Xcode command line tools can be run easily with xcrun  command. It gives us the ability not only to find the tools but also execute them. We can use ‘xcrun’ to find the swift toolchain

We can execute most of the Xcode command tools using ‘xcrun’. The most useful tool that can be used with ‘xcrun’ would be ‘simctl’ to manage Simulators using the command line. We can create, edit, erase and delete simulator using command line using ‘simctl’ e.g we can create

We can also delete, erase simulators using their identifiers. You can read more about xcrun here

xcscontrol

Xcode Server is Continuous Integration system provided by Apple. We can use xcscontrol to manage Xcode Server activities such as start, stop, restart the server. We can reset Xcode Server using

xctest

XCTest can be executed using xcodebuild , however, there is another tool we can use it for running our unit tests. We can use ‘xctest’ to run unit tests.

There are so many tools available but we are going to cover only these tools as part of this post.