Useful Aliases for Everyday iOS Development
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:
![](https://getuniversal.link/opengraph-image.png?87d3c38ed3d960f3)
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.
- Open your
.bashrc
or.zshrc
file:vim ~/.bashrc
orvim ~/.zshrc
- Paste your aliases at the end of the file.
- Save and reload the file:
source ~/.bashrc
orsource ~/.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.
![](https://indie.watch/content/images/2022/05/Twitter---Facebook-9.png)
![](https://getuniversal.link/opengraph-image.png?87d3c38ed3d960f3)