How to prepare your Linux/MacOS box for Ionic 3 development

The guide assumes the OS of your machine is High Sierra 10.13.3 for Mac users and Ubuntu 16.04 for Linux users. If a Linux distribution is used, please skip the iOS section and continue to the Android section.

INSTALL NODEJS

Download and install the latest LTS NodeJS from the following link:

Note: At the time this guide was written, the latest LTS version of NodeJS was 8.10.0.

INSTALL CLIS

To install the global dependencies run:

$ npm install -g ionic cordova


Note: This command will install the latest version of Ionic and Cordova. At the time this guide was written, the latest version of Ionic was 3.20.0 and Cordova was 7.1.0.

SDK ENVIRONMENT FOR IOS AND ANDROID PLATFORMS

To be ready to add and build the iOS and Android platforms, follow the steps below.

IOS

The iOS platform can be added on MacOS only. If you do not use MacOS, please skip this step and continue to the Android section.

INSTALL XCODE

Visit:

and install the latest Xcode version.

INSTALL COCOAPODS

From your terminal, execute the following command to install the latest version of CocoaPods.

$ sudo gem install cocoapods


ENABLE COMMAND-LINE TOOLS

Once Xcode is installed, several command-line tools need to be enabled for Cordova to run. From your terminal, run:

$ xcode-select --install

For more information on the iOS requirements, visit:

ANDROID

INSTALL JAVA SE DEVELOPMENT KIT 8 (JDK)

Visit Oracle’s website and install Java SE Development Kit 8.

INSTALL ANDROID STUDIO 3.X

Visit Android’s Studio page and install Android Studio 3.x.

LINUX USERS ONLY

If you are running a 64-bit version of Ubuntu, you need to install some 32-bit libraries. To determine what version of Linux is installed, open your terminal, type the following command at the prompt, and then hit Enter:

$ lscpu

The “CPU op-mode(s)” entry tells you what version of Linux you’re running. If your running a 32-bit version of Linux you’ll see only a 32-bit mode listed and you can stop reading here. If you running a 64-bit version, you’ll see both the 32-bit and 64-bit modes listed since a 64-bit processor can run both. In that case you need to install the following 32-bit libraries. From your terminal, execute the command:

$ sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386

INSTALL SDK PLATFORMS

After installing the Android SDK, you must also install the packages for whatever API level you wish to target. To do it, open the Android Studio, and click on Configure -> SDK Manager.

Then, from the side menu, select Appearance & Behavior -> System Settings -> Android SDK click on the SDK Platforms tab and select one or more versions of APIs to download, as shown:

INSTALL ANDROID SUPPORT REPOSITORY

Usually, Android Support Repository is already configured once you install Android Studio. If it’s not, go to tools -> SDK Manager from the menu and on the SDK Tools tab select to install the Android Support Repository.

INSTALL GRADLE

Sometimes, you may need to install gradle manually. To determine if Gradle is installed, open the Android Studio, and click on Configure -> Plugins.

Choose Enabled from Show and search for the Gradle plugin in the list.

If you can’t find the Gradle plugin you have to install it as directed at:

Note: Following the instructions of the aforementioned link, the latest Gradle distribution will be installed on your machine. At the time this guide was written, the installed Gradle version was 4.6.
For more information on the Android requirements, visit:

SET ENVIRONMENT VARIABLES

MACOS

On a Mac, you can use a text editor to create or modify the ~/.profile file. To set an environment variable, add a line that uses export like so and substitute the path with your local installation:

export ANDROID_HOME=/Users/YOUR_USER_NAME/Library/Android/sdk
export JAVA_HOME=/usr/libexec/java_home


LINUX

On a Linux, you can use a text editor to create or modify the ~/.bashrc file. To set an environment variable, add a line that uses export like so and substitute the path with your local installation:

export ANDROID_HOME=/home/YOUR_USER_NAME/Android/Sdk
export JAVA_HOME=/opt/java/jdk1.8.0_162/


SASS

To install Sass open your terminal and execute the following command:

$ npm install -g sass

For more information visit Sass site.

REFERENCES

Android Studio installation guide, Cordova iOS Platform Guide, Cordova Android Platform Guide, Gradle installation docs

Stay tuned

Join our list and sing up to get early access to our latest news and free tutorials about Ionic.