My development environment on macOS - Macbook Air M1

I maintain this note as my instruction for setting up macOS for development. Currently, I apply this on my Macbook Air M1 2020 - 16GB RAM and 512GB SSD.

My first experience with this laptop was pretty good. Right after receiving my new Macbook, I upgraded it to macOS Monterey 12.1 for the latest OS. I installed some software and tested out some tools I often use for development:

Daily Apps:

  • Google Chrome (from Chrome download page)
  • MS Office: Downloaded from my Office 365 account
  • My favorite window management tool for macOS: Rectangle
  • Anydesk for remote desktop control

Coding IDEs:

  • Visual Studio Code (from Microsoft)
  • XCode (from App Store) - The best IDE for macOS
  • Android Studio for Android Development

Utilities:

  • ZSH (preinstalled, but need configuration)
  • Brew (from Homebrew) - package management for macOS
  • Hugo (for maintaining websites and blogs)
  • CMake for C++ development

Others:

Some people complain about the bugs in the new Apple silicon (M1 chip). However, for a few days of using it, I didn't see much trouble in my development job.

1. How to install almost packages on macOS?

You can install a lot of software on macOS by three following ways:

  • Install from App Store. Just login into App Store with an Apple ID, and find and install the software.
  • Install from Homebrew. After install Homebrew for macOS (Homebrew), open the Terminal and type brew install <package name>.
  • Install from downloaded packages. Download from vendor websites, and run the installation wizard, or copy the application to the Applications folder of macOS (~/Applications).

2. Homebrew first!

Homebrew is a package manager for macOS, which is like apt on Ubuntu/Debian, yum on CentOS, or chocolately on Windows. Homebrew saves me a lot of time as I can use it for convenient package setup instead of going to software homepage, download each of them and install manually. To get brew installed, you need XCode first, and then install Homebrew using a bash script.

  • Step 1: Setup XCode

XCode is a development toolkit / IDE developed by Apple, which you may need to installed when using Macbook for development, especially for macOS and iOS development. It is also needed for Homebrew. Go to your App Store on your machine, search for XCode, and install it.

XCode

XCode

It takes me a long time to install XCode. The installation pack can be > 12GB, depending on the version you try to install. Take a coffee and relax, or keep doing other tasks in that time.

After installing, you may want to open XCode or use commandline to accept the developer license. You can do this by typing into Terminal:

1sudo xcodebuild -license

Scroll to the bottom and accept this license. In the recent XCode version, fortunately, you can use following line to accep the developer license quicker without reading.

1sudo xcodebuild -license accept
  • Step 2: Install Homebrew

After your XCode IDE has been installed, copy and paste this line to get Homebrew (I took it from Homebrew homepage):

1/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Add Homebrew to the PATH:

One more important step after installing Homebrew is to add it to you PATH. In the current version of macOS, ZSH is the default shell, so:

1echo 'PATH="/usr/local/bin:$PATH"' >> ~/.zshrc

If you are using Bash, replace ~/.zshrc with ~/.bash_profile.

1echo 'PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile

After this step, open a new Terminal to use Homebrew. One more tip is that you can use brew doctor to check your brew installation.

brew doctor

brew doctor

2. Install Daily Apps

Web browser - Google Chrome I don't hate the default browser, Apple Safari. Instead, this browser has a nice minimal design and naturally integrates best with macOS ecosystem. However, I also use other machines with Linux and Windows inside, so I choose to use Chrome to take advantage of synchronization feature from Gooogle. With Chrome, I can synchronize accounts, extensions, browser settings and passwords between my machines. You can download Chrome from the official download page or using brew to install:

1brew install --cask google-chrome

Chrome on my Mac

Chrome on my Mac

Microsoft Office: Apple has their own office toolbox including Keynote, Numbers and Pages. However, to ensure the consistency and compartibility between my devices, I buy and install Microsoft Office on my machines, including macOS. If you also bought MS Office, just login to your account and download your applications. MS Office support for macOS is pertty good.

Window management tool: My favourite window management tool on macOS is Rectangle. If you want to arrange your windows with keyboard shortcuts, for example putting VS Code on the left and Chrome on the right, Rectangle is the right tool for you. After installing Rectangle, I can use ⌃ + ⌥ + ← to align a window to the left half of the screen, while ⌃ + ⌥ + → to put another window on the right. It a common setup pattern for me, and you can discover other shortcuts in Rectangle settings.

Arrange VS Code and Chrome with Rectangle

Arrange VS Code and Chrome with Rectangle

Install Rectangle using Homebrew:

1brew install --cask rectangle

Anydesk: This is my choice for daily remote desktop control. You can consider Teamviewer or Chrome Desktop Remote too. I prefer Anydesk because it is a free and powerful solution. The binary size is also pretty small. Go to Anydesk.com to download your app or:

1brew install --cask anydesk

3. Coding IDEs

Below are three IDEs I will need for my daily job. Let's get them installed.

  • Visual Studio Code (from Microsoft)
  • XCode (from App Store) - The best IDE for macOS
  • Android Studio for Android Development

VS Code

Visual Studio Code is my favorite code editor and the program I spend most of my time. I downloaded the installation package from Microsoft for my machine. However, if you installed Homebrew before (see Untilities in the next section), you can also use brew to install VS Code (link). After installing, I often synchronize my settings and setup font for VS Code environment.

1brew install --cask visual-studio-code
  • Synchronize settings for VS Code

I usually switch between my machines (on both macOS, Ubuntu and Windows), so I synchronized my VS Code Settings using my Github account (this is an internal feature of VS Code). If you want to use my settings as a reference, you can find my setting file here.

  • Setup Fira Code font

In my VS Code settings, I use Fira Code as the default font for coding. I like the feature that joins multiple character into one (for example => into 1 arrow ⇒, or showing == as only 1 long =). To install this font on macOS, you need to go to font releases page, download the latest version and install ttf files using macOS FontBook.

FiraCode

FiraCode

Note: Installing XCode first is also required for Homebrew setup on the next section.

Android Studio for Android app development

Sometimes I need to build some Android applications on my machine. That's why I need Android Studio. This IDE (and also Android emulator) can now run smoothly on mac M1 with native support for Apple Silicon. Install:

1brew install --cask android-studio

The build time on my Macbook Air M1 (16GB RAM - 512GB SSD) is pretty good (often better than my i5 8400 - 16GB RAM desktop). Tip: If your emulator freezes when running apps, try increasing RAM or heap size of your virtual device.

4. Utilities

Terminal setup

Almost developers spend a lot of time with their terminal, so setup a Terminal environment they are familar with is important.

ZSH Shell is my favourite shell (Just like the default Bash in Ubuntu). I often use it on my development machines because of super cool features ZSH can provide. Fortunately, macOS has this shell as default, and I only have to confugure it.

1sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
1git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Add the plugin to the list of plugins for Oh My Zsh to load (inside ~/.zshrc):

1plugins=( 
2    # other plugins...
3    zsh-autosuggestions
4)
  • iTerm 2: The default Terminal app on macOS is just fine. However, iTerm 2 is prefered by many developers thank to high customizability and useful features (for exmaple spliting terminal windows). Install iTerm 2 using brew. From now on, when I use "Terminal", I mean you can use default Terminal or iTerm 2.
1brew install --cask iterm2

I also change color preset to Solarized Dark in iTerm2 Preferences.

iTerm2 Preferences

iTerm2 Preferences

You can also setup attractive theme for Terminal with powerlevel10k (link).

  • Other Terminal utilities:

You may want to install following utilities: tmux, htop.

1brew install tmux
2brew install htop

Hugo - Static site generator

I develop and maintain some websites on Hugo - a lightweight but powerful static site generator. This blog is also written using it. To install Hugo with Homebrew, type into your Terminal:

1brew install hugo

This command installs hugo-extended version. On other platforms, we should find extended version of hugo to install; however, in macOS, the default version is hugo-extended, so just one line. My installed package is also the latest one. When using apt to install Hugo on Ubuntu, I only receive a very outdated version, so I have to download and install hugo from Github release manually.

CMake

macOS comes with a default C++ compiler, so we may not need another to compile C++ for macOS. I often use CMake to write make files. Download and install CMake from the official download page or brew (may be outdated):

1brew install cmake

Or for CMake GUI

1brew install --cask cmake # CMake GUI

Launch CMake GUI from Launchpad or Spotlight to verify if it works.

Thanks for reading my note. This note will be update gradually when I recognize something I need on my machine on daily development environment. Feel free to put a comment for your own package setup and ask question about my experiences with my Macbook Air M1.

Related Posts

How do I install Ubuntu on a new machine?

Viet-Anh maintains this note as an instruction to install Ubuntu on a new machine and setup development environment as fast as possible.

Read more

Install Zsh and Auto suggestion plugin for Ubuntu

ZSH, also called the Z shell, is an extended version of the Bourne Shell (sh), with plenty of new features, and support for plugins and themes.

Read more

Install OpenCV 4 on macOS using Homebrew

This is my note on how to install OpenCV 4 on macOS with Homebrew. I tested this tutorial on my Macbook Air 2020 with Apple silicon (M1 chip).

Read more