Xcode Custom Behaviours

Karthik
3 min readAug 5, 2021

--

This article is about using user-defined scripts for initiating certain tasks at ease.

Xcode users oftentimes encounter a situation where they need to run the pod install. The classic way of pod install is cd’ing the project root folder to the terminal. Wouldn’t it be nice to run pod install by the keyboard shortcut ?, Yes, there is a way to attain the behavior, that is Custom Behaviour.

Custom Behaviors:

  • launch script ( pod install, git commit, open project root folder )
  • play sounds ( Ding )

Custom scripts:

Let us create a custom script to run the pod install and opening finder via Xcode custom behavior.

Script: Opening finder
Script: Running pod install

Adding Custom Behaviors:

Now it's time to add the custom scripts which we have created above into Xcode. Under Xcode->Behaviors->Edit Behavior -> + Add

Once the custom script is been added, let's change the keyboard shortcut by clicking the ⌘ symbol next to the script name (“New Behavior” above) to set the keyboard shortcut. you can choose your desired shortcut and give some time to your fingers to get memorized.

  • pod install: cmd + shift + p
  • open finder: cmd + shift + f

Make sure you aren’t violating your existing muscle memory. say for eg: we often use cmd + shift + O for searching inside the project. it should not be used for any other keyboard shortcuts.

Note: We should remap everything whenever the Xcode update happens.

Playing Sounds:

I am a big fan of flight ding waves (custom sound) and ship shrunk (from Xcode) sounds. I configured it in a way that Xcode plays ding 🔈 when the build and unit test succeeds and shrunk ⛴ plays when Xcode failed to build the project. it helps me a lot of times when I wasn’t looking at Xcode once after the test/build starts.

Success and failure sound configuration

A small investment that pays dividends 😎

Saving just two minutes a day adds up to an entire day of work every year.

That’s it for this time! 👏👏👏 Feel free to comment if you have questions and follow to get notifications about future articles.

“Be the senior engineer you needed as a junior.” — Someone

--

--