Configuring macOS For Software Development

So you got yourself a new machine and configuring macOS for software development is presenting a bit of a challenge? Perhaps looking back at your old machine you wish it had been a bit cleaner setup? Well I sure do. This post will be a living post where I keep adding upmacOS for Developers the tips and tricks on macOS for a software developer. We’re going to be starting from a clean MacBook Pro 2016 with macOS Sierra 10.12.4.

Basic Software That is Handy

I’ll first get a bunch of productivity software installed including:

  1. Chrome and/or Firefox Developer Edition
  2. Collab tools – Skype, Slack, etc.
  3. Sublime Text 3
  4. Postman
  5. XCode and XCode command line tools – now I have git! Even if you are not developing iOS or macOS apps install it.
  6. Box.com – simple and easy file synch from one machine to another (dropbox.com is another option).

Configuring macOS For Software Development – Configuration Basics

Using macOS for software development requires editing environment settings (PATH and stuff like that ). They are set by editing the .bash_profile file in your user’s home directory. There are lots of ways to edit this file, but from a terminal using nano is the simplest thing to do.

Other macOS configuration items I like to have:

  • Put the screen lock back on the menu bar so it is easy to lock your screen when you step away for coffee.
    • Go into Keychain Access and then get into the Preferences to enable the lock icon.
    • Go into Security and Privacy if you want to add a custom lock message.
  • Add a custom login screen image by dropping an image into /Library/Caches if you like
    • The image must match your screen’s resolution exactly

Customizing the Menu Bar

The menu bar looks to be a great productivity enhancement. The settings are in the keyboard preference control panel. Open up the panel and then literally drag icons from the panel and off-screen to the bar. The pointer will locate and light up on the bar, just keep dragging until you see it. Do the opposite to remove a button. If you get stuck try here: https://macperformanceguide.com/blog/2016/20161118_2304-2016MacBookPro-touchbar-Siri.html

Configuring macOS For Software Development – Tools

Homebrew will be the main configuration/dependency manager that I will use to configure macOS for software development. NPM will have to be used for Node.JS stuff, but I’ve learned that whenever possible using Homebrew is the best way to keep things simple. This is particularly true for anything you’ll be using from the command line and anything that will be running as a service, server, or part of a web development framework.

I’m also generally going to say that you really should not use any of the developer tools that ship with macOS for software development. PHP, Python, and Java to name a few. These should all be replaced with clean builds using Homebrew (or another package manager). Why? Because Apple tends to mess with them and definitely will update them with macOS updates so anything you do to customize them can get wiped out. Better to just install clean versions outside of Apple’s reach.

Don’t forget that “which” is your friend. If something isn’t working right, maybe you’re calling the wrong binary. To see which python you are using “which python” will tell you the location of the binary. Homebrew will symlink them to /usr/local/bin/ so if you get something other than that, then you’ll need to check/repeat your brew install.

  • To install homebrew, use this command:
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

    Make sure it works by running “brew doctor”

  • Install Node.JS and NPM with hombrew (“brew install node”)
    export PATH="/usr/local/bin:$PATH"
    Make sure it works by installing something like express. Use the -g option for express.
  • Its a good idea to set all the “names” for your machine to the same thing or you can have odd problems:
    scutil  –set ComputerName “some name”
    scutil –set LocalHostName “some name”
    scutil –set HostName “some name”
  • Install Java and JDK (Provided this gist still is around at the time of reading, otherwise…)
    You can see my various posts on Java, but they are always changing. Currently this will do the trick:

    • brew cask install java
    • Then edit your .bash_profile to include Java home: export JAVA_HOME=$(/usr/libexec/java_home)
  • SSH Keys – add them to github and/or bitbucket.
    • Create new ones using instructions here.
      Copy to the clipboard with: pbcopy < ~/.ssh/id_rsa.pub
      Add it to your local agent so you don’t have to type the passphrase everytime: ssh-add ~/.ssh/id_rsa
    • Move Your Existing SSH Keys From a Current MBP (optional)
      • Easiest way is to cp ~/.ssh/id_rsa* /Users/yourHome/keys
      • Zip them and either move via box.com or a USB stick to the same place on the new machine
      • If you are using multiple key sizes don’t forget to also grab the config file that tells your machine when to use which key
  • Check Apache httpd
    • You can use the default or install a clean apache with brew. Highly recommend installing httpd with Homebrew
      • Use: brew install httpd24 –with-privileged-ports –with-http2
    • When using the pre-installed one, the main config files are in /etc. When using httpd installed with Homebrew then the configuration files will be in: /usr/local/etc/apache2/X.X/httpd.conf corresponding to the version you have installed.
    • You can confirm where the httpd.conf file is with this command: apachectl -t -D DUMP_INCLUDES
    • Ensure that the PHP mime type is in the httpd.conf file
      • AddType application/x-httpd-php .phtml .pwml .php5 .php4 .php3 .php2 .php .inc .htm .html
  • Update Apache httpd to point to a webroot in your home directory
    • You will need to update permissions so that _www can access and execute files.
  • Install MySQL
    • MySQL WorkbenchYou can install it with brew or from the download. I did use the binary installers for both MySQL and the Workbench.Why did I break my rule? Installation of the GUI Workbench software seemed easier by just downloading it. Its not updated very often and since there are full GUI installers that are pretty reliable I went this way. Also – unlike Java, you don’t need to access this one from the command line so you do not have the trouble as with Java installers and conflicts with which Java you are trying to execute.
  • Install PHP
    • brew tap homebrew/dupes
    • brew tap homebrew/versions
    • brew tap homebrew/homebrew-php
    • Install php and a new apache httpd: brew install php71 –with-httpd24
    • Or just php and then configure it with the apple installed apache: brew install php71
    • You will need to update the php shared object location in http.conf
      • Hombrew should update the conf files correctly. Check the httpd.conf file to make sure the Load Module command for PHP is correct. The config file should be in /usr/local/etc/apache.
      • Make sure there is a php type: AddType application/x-httpd-php .php in the mime_module section
  • Android Studio (Canary is here. Stable is here.) is great for Android development and can be installed with the binary installer. Pretty self explanatory for updating it. There’s an internal SDK manager you can find with this button for updating Android SDK materials —->
  • PHPStorm (PHP IDE) and IntelliJ (Java IDE) – pretty straightforward binary installers from Jetbrains.
  • If you need to work with Tomcat:
    • Confirm the right JRE is working from terminal
    • Install with homebrew: brew install tomcat
    • Update the config file located in /usr/local/Cellar/tomcat/[version]/libexec/conf/tomcat-users.xml to contain a user with privs to the admin gui
      <user username=”admin” password=”a_password” roles=”tomcat,manager-gui”/>
    • Optionally add the bin to your .bash_profile
    • start it up with /usr/local/Cellar/tomcat/[version]/bin/catalina run
  • I mentioned above using the git installed with XCode, for more git tips see my post here.
  • If you need to work with Node.JS:
    • install Node with brew: brew install node
    • Then you can install packages, use -g to globally install key things like express and bower

Configuring macOS For Software Development – Keeping the Machine Updated

Regular maintenance is the key to keeping your machine in good shape.

Maintain all your brew installed stuff with:

brew update

brew doctor

brew upgrade

Its good to visit the doctor so be sure to run that every once in a while. That third command will upgrade everything you’ve installed. That can take a while. Specify a package name to just upgrade one thing.

Maintain Node.js packages with:

npm update -g or npm update in a directory with a packages.json file.

The other thing that can help quite a bit is to prune things you are not using. If you are no longer working with a framework then remove it from your machine. This also includes code – I tend to look at lots of stuff and build up a lot of old projects that I don’t really need. Keeping down the clutter, just like keeping your basement clean, can really help out in times of trouble. This is another great use of box.com or dropbox.com (insert your tool of choice) – move thing you aren’t using there and get them off your local machine.

Conclusions

Hopefully this has helped you configure macOS for software development. I’ll be updating this regularly as I learn new things all the time that I do not want to forget. I’ll post change log here at the end.

Leave a Reply