Ionic Framework で iOS アプリをシミュレーターで起動する方法

Ionic Framework で iOS アプリをシミュレーターで起動する方法をご紹介します。

Ionic Framework | アイオニック フレームワーク

Ionic 前提環境

ionic -v
# 3.19.1
 
cordova -v
# 8.0.0

Ionic で iOS アプリをビルドする

まず、ionic cordova コマンドで iOS アプリをビルドします。

ionic cordova build ios

たくさん出力されますが BUILD SUCCEEDED が表示されれば成功です。

> cordova platform add ios --save
Using cordova-fetch for cordova-ios@~4.5.4
 
Adding ios project...
 
...
 
** BUILD SUCCEEDED **

Xcode で起動する

ionic cordova build ios すると platforms/ios ディレクトリに以下のようなファイルが生成されます。

$ ls -l platforms/ios 
total 32
drwxr-xr-x   7 youruser  staff   238  2 21 22:20 CordovaLib
drwxr-xr-x   4 youruser  staff   136  2 21 22:21 build
drwxr-xr-x  26 youruser  staff   884  2 21 22:20 cordova
-rw-r--r--   1 youruser  staff    48  2 21 22:21 frameworks.json
-rw-r--r--   1 youruser  staff  2951  2 21 22:21 ios.json
drwxr-xr-x  14 youruser  staff   476  2 21 22:20 your-app
drwxr-xr-x   3 youruser  staff   102  2 21 22:20 your-app.xcodeproj
drwxr-xr-x   4 youruser  staff   136  2 21 22:20 your-app.xcworkspace
drwxr-xr-x   7 youruser  staff   238  2 21 22:21 platform_www
-rw-r--r--   1 youruser  staff   860  2 21 22:20 pods-debug.xcconfig
-rw-r--r--   1 youruser  staff   859  2 21 22:20 pods-release.xcconfig
drwxr-xr-x  12 youruser  staff   408  2 21 22:21 www

.xcodeproj という拡張子のファイルを開くと Xcode が起動します。

open platforms/ios/your-app.xcodeproj

最後に、Xcode 上で ▷ 再生ボタンをクリックすれば iOS Simulator が起動するので、Ionic Framework で開発した iOS アプリの動作確認ができます。

以上、Ionic Framework で iOS アプリ開発をやっていきたい現場からお送りしました。

参考情報