どうも、フリーランスエンジニアのyoshikiです。
前回はWindows編の環境構築方法を説明しましたが、今回はMacでの構築方法を説明していきます。Macの場合はほとんどコマンドラインから作ることができます。
Node.jsインストール
Node.jsをバージョン管理するためのnodebrewをインストールし、インストール先のパスを.bash_profile(ログイン時に読み込まれる設定ファイル)に設定します。
1 2 3 4 5 6 |
curl -L git.io/nodebrew | perl - setup echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile source ~/.bash_profile nodebrew install-binary stable nodebrew ls nodebrew use v8.6.0 |
IonicとCordovaインストール
IonicとCordovaを同時にインストールします。
1 |
npm install -g ionic cordova |
JDKインストール
JDKをこちらからダウンロードします。
「Accept License Agreement」をチェックして、Mac用をダウンロードします。
環境変数の設定をします。
1 2 3 4 5 |
echo 'export PATH=$PATH:/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin' >> ~/.bash_profile echo 'export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home' >> ~/.bash_profile source ~/.bash_profile echo $PATH echo $JAVA_HOME |
Android SDKインストール
こちらからAndroid Studioをダウンロード&インストールします。(特に気にする箇所はないので、割愛します。SDKをダウンロードしてください。)
次にAVD Manager(Tools→Andoroid→AVD Manager)を起動し、デバイスの追加を行います。(Create Vertual Device)
環境変数の設定をします。
1 2 3 |
echo 'export PATH=$HOME/Library/Android/sdk/tools:$PATH' >> ~/.bash_profile echo 'export PATH=$HOME/Library/Android/sdk/platform-tools:$PATH' >> ~/.bash_profile source ~/.bash_profile |
プロジェクト作成&起動
1 2 3 4 |
ionic start myApp-test tabs 以下のコマンドを実行して、エミュレータが起動すれば成功です。 cd myApp-test ionic cordova emulate android |