官术网_书友最值得收藏!

Basic Ionic CLI commands

Ionic commands help you smoothly create a new project and test it easily while you are developing it. The first command you should learn to execute is the ionic info command. This would help you to know all about your system environment that you have set up so far. If there are any errors, you can debug and resolve them before beginning the development.

The command and a sample output is given here:

$ ionic info
Your system information:
OS: Mac OS X Yosemite
Node Version: v0.12.4
Cordova CLI: 5.1.1
Ionic CLI Version: 1.6.2
Xcode version: Xcode 6.4 Build version 6E35b
ios-sim version: 3.1.1
ios-deploy version: 1.7.0

Another quick utility command is to go to the Ionic docs for a specific topic:

$ ionic docs <TOPIC>

Please go through the commands in this section in order to understand the steps required to build a dummy app to test the environment.

The next command to learn is to start a new project. Ionic has multiple flags/options along with this command to set up your project initially. The main command is as follows:

$ ionic start [OPTIONS] <PATH> [template]

The options are many, including –appname to set the name, --no-cordova to create a structure without Cordova (for cloud builds such as a phonegap build service), --template for selecting the initial template, and so on.

If you want to preview your app in a browser during the development phase, this is the most important command for it. It has a handful of useful options for setting a port number, opening a specific browser, printing console logs, and so on:

$ ionic serve [OPTIONS]

In order to add a platform, please run the following command:

$ ionic platform [OPTIONS] <PLATFORM>

After adding the platforms we want to build, we can run our app on an actual connected device using this command:

$ ionic run [OPTIONS] <PLATFORM>

Note

In order to run an app on an Android device, enable Developer Options and check the USB Debugging option in the settings. More info is available at http://developer.android.com/tools/device.html.

We can make the app build for all the platforms in one go or a specific platform by mentioning its name in the following command. It builds the apps locally using the native SDK tools:

$ ionic build [OPTIONS] <PLATFORM>

Hybrid App development relies on the web view or the browser in the native SDK of the platform. Ionic provides a way to change the browser of a specific app, for example, using the crosswalk browser. There is a command to list the available browsers:

$ ionic browser list

Add a new browser for any platform and also have the ability to revert back:

$ ionic browser add crosswalk
$ ionic browser revert <PLATFORM>

Or else you can use the following command:

$ ionic browser rm crosswalk

Ionic provides a way to list and manage extra add-ons or browser packages to your app using the Ionic CLI, which we will learn in future chapters.

主站蜘蛛池模板: 丰城市| 文水县| 新野县| 浦东新区| 乡城县| 麻阳| 杭锦旗| 克山县| 崇阳县| 宿州市| 民县| 平阳县| 唐山市| 锡林浩特市| 饶河县| 遵化市| 专栏| 镇沅| 太仆寺旗| 木里| 米林县| 和林格尔县| 体育| 南木林县| 白沙| 武鸣县| 晋中市| 永寿县| 崇义县| 深泽县| 建阳市| 元朗区| 荥阳市| 中宁县| 池州市| 平昌县| 邻水| 博野县| 安福县| 巧家县| 屏东市|