The Productive Apple Developer
Introduction
In this guide, I would like to take the opportunity to introduce some tools and techniques to dramatically improve your productivity developing for Mac and iOS. Many of these techniques are something I use on a daily basis and they have helped reduce a lot of repetitive and mundane tasks and make me an ever happier Apple developer. This is called applying the DRY principle from code to OS tasks. For example, if you find yourself renaming multiple files into "duck1.png" and "duck2.png" and so on, something is wrong. We Apple developers should never ever repeat ourselves, since we are too busy playing the next gadget from Cupertino, right? Without further delay, let's get started shall we?
Terminal
Terminal is a program included with all versions of Mac OS X. It is located in the Utilities folder within the Applications folder. When launched, it provides a line interface to control the underpinnings of the UNIX based operating system. The default UNIX shell in Mac OS X Panther (10.3) or later is Bash.
For a developer, terminal is arguably one of the most important tools in Mac.
iTerm 2 - Terminal on Steroid
iTerm 2 is my favorite replacement for the default Terminal application. It is highly customizable and has many supports like tabs, colors, profiles and custom key bindings. If you are used to moving from word to word in Xcode, or other editors by using "Option + Left Arrow/Right Arrow", rejoice! Because you can set up these same behaviors in iTerm 2 with little effort:
- Go to Bookmarks > Manage Profiles.
- Expand Keyboard Profiles and click Global.
- Click the + (Add Mapping) button.
- Choose cursor left from the Key drop down menu.
- Select the Option Modifier checkbox.
- Choose send escape sequence from the Action drop down menu.
- Enter b and click OK. You can now use Option-Left Arrow to move left/backward from word to word.
- Click the + (Add Mapping) button again.
- Choose cursor right from the Key drop down menu.
- Select the Option Modifier checkbox.
- Choose send escape sequence from the Action drop down menu.
- Enter f and click OK. You can now use Option-Right Arrow to move right/forward from word to word.
Brew, Homebrew
Homebrew provides a straightforward and flexible way to install UNIX tools that are not included with OSX.
In short, Homebrew is a Mac version of apt-get, gem, or aptitude. It manages UNIX tools. If you are terminal user, after using Homebrew your life will be forever changed. In fact, I bet you can't stop using it after you tried. Other similar package management systems in Mac are MacPorts or FINK. I don't like these as much because they are outdated and unstable.
Installing Homebrew is simple:
/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
Examples of using brew to install softwares:
$ sudo brew install wget
$ sudo brew install git
$ sudo brew install curl
$ sudo brew install git bash-completion
Things move pretty fast in brewland. If you don't update your brew after 24 hours, you will get a warning message. Update method is just what you can imagine:
sudo brew update
iTerm 2 with Finder: Go2Shell
What's your most used Terminal command? I bet it is "cd bala bala". Your situation goes like this: you open your good friend Finder, go to your project folder, coding, open iTerm 2(I hope you are using it now, :)), cd ~/balabala/myproject/, and do git. Using "cd" all day long is absolutely the most annoying thing. Go2Shell is much simpler.
Go2Shell opens a terminal window to the current directory in Finder

Customize your .bashrc
I personally like Bash more than the others, but if you are using sh or zsh, the idea is the same - take the time to customize your own profile to make your workflow more efficient. It is located in ~/.bashrc. It is the first to load when you open your iTerm 2 window. Use alias command properly to reduce the heavy loads. Alias just replaces a word by another string. Some examples:
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias sshc='ssh root@www.nanaimostudio.com'
alias cdo='cd ~/Documents/Projects/OpenSourceProjects/'
alias cdp='cd ~/Documents/Projects/'
alias s='subl'
There are lots of tutorials talking about how to customize your bash. I will show a few of my own here because it would take a very long chapter to introduce all of them.
Don't put duplicate lines in the history.
HISTCONTROL=ignoredups:ignorespace
Append to the history file, don't overwrite it
shopt -s histappend
For setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
Check the window size after each command and, if necessary, update the values of LINES and COLUMNS.
shopt -s checkwinsize
Set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
Some tricks you might like
I can't help to talk about the following tricks. It might be a little off topic so I will go as quickly as possible. These are very good tricks.
- cd - takes you to the previous directory you were in.
- !! repeats your last command. Most used in the form of "sudo !!"
- ESC . insert the last arguments from your last bash command.
- ls -thor list the most recently modified files in a conveniently readable format.
- history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -nr | head top 10 commands used.
- pushd and popd almost always come in handy
- for file in *.wav; do lame "$file" "$(basename "$file" .wav).mp3" ; done; Loop
Finder or Path Finder
The original Finder is not very good. It is elegant indeed, but not that convenient. If you have ever used TotalCommand, you will know how powerful a file manage software can be. Path Finder offers additional capability and control. It is a commercial software and costs $40. I have tried it few times - Path Finder is a great software and worth the price, but I like the simple Finder window more. It is just a personal preference. If you haven't used Path Finder yet, you should give it a try.
If you are sticking with Finder, there are some tricks that can make it better. Please leave a comment if you have any suggestions.
- Rename: type "enter" in any selected file name
- Create New Folder: Command + Shift + N (New)
- Connect to Server: AFP:// for mac, SMB:// for windows, or even FTP:// . Shortcut: Command + K
- Go to the Folder: Command + Shift + G (GO)
- Command + 1~4 to switch view
- Command + N to open a new Finder window
- Command + I to get the information on a Folder or File.
FTP
You need a FTP GUI client. Why? There is no reason not to get it and plenty of reasons why you should have one.
Filezilla I don't recommend it. It is a cross platform FTP software, but visually it's not Mac-styled.
Cyberduck My #1 choice of free FTP client. Clean and fast, with support for FTP, SFTP, WebDAV, and cloud storage like Google and Amazon Cloud.
Transmit Commercial software, costs $34. Since I don't have that much requirement for FTP transmissions. I haven't got a copy for it.
Automator
Automator can automate lots of things in Mac and you don't need to remember a bunch of command and type them in the folder. There is one time, our client send us assets with ipad2 and ipad3 suffix in the filename. We need to rename them all to normal name (no suffix) and retina version (with @2x suffix). With Automator, it is all done in just a few clicks.
- First, launch Automator and create a new service. Name whatever you want.

- Second, drag two items: "Get Folder Contents" and "Replace Text" into the work flow. Set other parameters as the image shown below:

- Save and use it. Select any file or folder in Finder. Choose Finder -> Service -> Rename__(Script name you typed). A window will popup for renaming.
Optimization
After a using Mac for a while, it becomes slower and slower. There are something we can do to make it faster. I will explain each one of them so you can know how to speed it up or bring it back if any error shows.
- First, run Disk Utility to perform a Repair Disk Permissions. It is harmless and can reduce some rare errors. I recommend that you run it once for a while.

- Clean history, system cache and application caches using CCleaner or iBoostUp. You can also use CleanApp to uninstall an app and remove it's related files. It is an important step to rejuvenate your Mac.
- Double check if you are using NTFS driver like Paragon NTFS, turn it off if you are not using it. The reason for it is that if you enable spotlight(you should), it will try to create the index in your NTFS partition, which will make the whole system extremely slow. If you have to use it for writing files to NTFS disk, disable spotlight indexing on NTFS disk.

- Disable unused items in Login Items window. There are lots of things you don't need to start it every time you boot your sweet Mac. They are just slowing it more and more. Disable them, leave your favorites only!.

- Validate Fonts, some broken or duplicated fonts can also cause problem of slowing the dear Mac machine. Open Font Book App, select all fonts, and then File -> Validate Fonts. Fix error if any shows on Font Book.
- Turn off Speech Recognition, and Internet Sharing if you don't use them. You can also turn off Universal Access and Bluetooth, but "Universal Access" is used by Accessior which is a great software I will introduce later, and my keyboard and mouse are using Bluetooth. I left these two on.
- Clean out your unused widget.
- Use Onyx to do maintenance. The official site is www.onyxmac.com. Be careful to click the right download link which is http://www.titanium.free.fr/download.php Be careful of doing anything on it.
- Additionally, you can clean up Launch Service. The files can be found at
~/Library/LaunchAgents
/Library/LaunchAgents
/Library/LaunchDaemons
After you install Adobe Master Suite, Autodesk Maya, or TeamViewer, they run some background services on your future login (annoying isn't it?). Just clean the files in the three folders above to disable them. Be sure to backup these files first. More explanation:
Launch daemons can run without a user logged in and it cannot display information using any GUI. The configuration plist files for launch daemons are stored in /System/Library/LaunchDaemons folder (for things provided by Apple) and /Library/LaunchDaemons (for everything else)
Launch agents run on behalf of a user and therefore need the user to be logged in to run. launch agents can display information through the window server. As with launch daemons, launch agent configuration plist files are stored in the /System/Library/LaunchAgents and /Library/LaunchAgents. User launch agents are installed in the ~/Library/LaunchAgents folder.
Conclusion
So that wraps up a few of the best and most useful tools we use as Apple developers. Hope this will make you a more productive Apple developer! What other tools do you use? Comment below so we can compare. Love the list of tools we have introduced? Well then share the developer love on Twitter or Facebook!
Boon Chew |
2 Comments |
Apple,
idevblogaday,
productivity,
tools in
idevblogaday 

