Useful Aliases for Everyday iOS Development

Useful Aliases for Everyday iOS Development
Photo by Goran Ivos / Unsplash


In this post, we'll cover a bunch of handy aliases for Xcode, CocoaPods, Git, and more that will help make your workflow more efficient. These tips will help you spend less time context switching and more time coding.

ℹ️ We'll look at how to add these to your .bashrc file at the end.

Disclaimer: I don't use or endorse all of these aliases equally - use whichever ones make sense to you.

Git

# Show the status of the working directory and staging area
alias stat='git status'

# Show a compact log of commits with a graphical representation of branches
alias glg='git log --oneline --graph --decorate'
# Display a compact log of commits with custom formatting
alias glp='git log --pretty=format:"%h - %an, %ar : %s"'

# List local branches
alias gb='git branch'
# List all branches, including local and remote
alias gba='git branch -a'

# Commit with a message
alias gcm='git commit -m'
# Commit all changes to tracked files
alias gca='git commit -a'
# Commit all changes to tracked files with a message
alias gcam='git commit -am'
# Amend the last commit
alias gcae='git commit --amend'

# Undo the last commit but keep the changes staged
alias gundo='git reset HEAD~1 --soft'
# Discard all changes and reset to the last commit
alias gtoss='git reset --hard'

CocoaPods

# Install the pods specified in the Podfile
alias podi='pod install'

# Install the pods and update the repo to ensure the latest versions are fetched
alias podiru='pod install --repo-update'

# Update all pods to the latest versions allowed by the Podfile
alias podu='pod update'

# Remove the Pods directory and Podfile.lock, then reinstall all pods
alias podnuke='rm -rf Pods Podfile.lock && pod install'

Derived Data

# Deletes the DerivedData folder
alias ddd='rm -rf ~/Library/Developer/Xcode/DerivedData/*'

iOS Simulator

# Erase all simulators
alias simerase='xcrun simctl erase all'

# Change a particular user default value
# Usage: simdefaults [APP_BUNDLE_ID] [DEFAULTS_KEY] [VALUE]
alias simdefaults='xcrun simctl spawn booted defaults write [APP_BUNDLE_ID] [DEFAULTS_KEY] [VALUE]'

# Open a deep link
# Usage: simdeeplink [URL_SCHEME] [URL_PATH]
# Usage: simdeeplink turo://search
alias simdeeplink='xcrun simctl openurl booted'

# Set location
# Usage: simlocation [LATITUDE] [LONGITUDE]
# Usage: simlocation 37.7749 -122.4194
alias simlocation='xcrun simctl location booted set [LATITUDE] [LONGITUDE]'

# Adjust privacy settings
# Usage: simprivacy [SERVICE] [ACCESS_LEVEL]
alias simprivacy='xcrun simctl privacy booted grant [SERVICE] [ACCESS_LEVEL]'

# Handle push notifications
# Usage: simpush [PAYLOAD_PATH]
alias simpush='xcrun simctl push booted [APP_BUNDLE_ID] [PAYLOAD_PATH]'

# Reset all user defaults for a particular app ID
# Usage: simresetdefaults [APP_BUNDLE_ID]
alias simresetdefaults='xcrun simctl spawn booted defaults delete [APP_BUNDLE_ID]'

I'm usually only working on one app at any given time, so I hardcode the aliases to include the relevant Bundle ID, URL Scheme, etc., so I only need to provide a value for the "last" parameter:

# Basic Alias
# Usage: simdeeplink [URL_SCHEME] [URL_PATH]
# Usage: simdeeplink turo://search
alias simdeeplink='xcrun simctl openurl booted'

# What I Use
# Usage: simdeeplink search (resolves to ....booted turo://search)
alias simdeeplink='xcrun simctl openurl booted turo://'

For easier testing of Universal Links and your Apple App Site Association file, check out:

Universal Link Checker & Apple App Site Association (AASA) Validator
Easily verify and test Universal GetUniversal.link is a free tool for verifying and testing Apple App Site Association (AASA) files. Ensure your Universal Links are configured correctly with easy link creation, real-time testing, and team collaboration features. Save the website as a bookmark for quick access on devices and simulators. Simplify your AASA file troubleshooting today!

Xcode Project Management

# Open the Xcode workspace file
alias xcworkspace='open *.xcworkspace'

# Open the Xcode project file
alias xcproject='open *.xcodeproj'

# Open the Xcode workspace if it exists; otherwise, open the Xcode project file
alias xcopen='open *.xcworkspace || open *.xcodeproj'

Misc.

alias .="cd .."
alias ..="cd ../.."
alias ...="cd ../../.."

alias cl="clear"

Adding Custom Aliases

When you start a new terminal session, your shell (Bash or Zsh) reads and executes the commands in the corresponding configuration file - .bashrc for Bash and .zshrc for Zsh.

If you want to customize your shell experience with custom commands, you'll need to add these aliases to those files.

If you're using the native Terminal app on your Mac, you'll want to edit the .zshrc file.
  1. Open your .bashrc or .zshrc file: vim ~/.bashrc or vim ~/.zshrc
  2. Paste your aliases at the end of the file.
  3. Save and reload the file: source ~/.bashrc or source ~/.zshrc

Those aliases should now be ready to use.


If there's any useful ones I've missed, shoot me a message on Twitter or at [email protected] and I'll add it here.

And, if you're an indie iOS developer, make sure to check out my newsletter! Each issue features a new indie developer, so feel free to submit your iOS apps.

Ace The iOS Interview
The best investment for landing your dream iOS jobHey there! My name is Aryaman Sharda and I started making iOS apps way back in 2015. Since then, I’ve worked for a variety of companies like Porsche, Turo, and Scoop Technologies just to name a few. Over the years, I’ve mentored junior engineers, bui…
Indie Watch
Indie Watch is an exclusive weekly hand-curated newsletter showcasing the best iOS, macOS, watchOS, and tvOS apps from developers worldwide.
Universal Link & Apple App Site Association Testing Tool
Easily verify and test Universal GetUniversal.link is a free tool for verifying and testing Apple App Site Association (AASA) files. Ensure your Universal Links are configured correctly with easy link creation, real-time testing, and team collaboration features. Save the website as a bookmark for quick access on devices and simulators. Simplify your AASA file troubleshooting today!

Subscribe to Digital Bunker

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe