{"_id":"56d1f33d00a2a70b00b365e0","parentDoc":null,"version":{"_id":"56d1f33700a2a70b00b3658e","project":"5526c95cf69851170038b48f","__v":2,"createdAt":"2016-02-27T19:04:23.946Z","releaseDate":"2016-02-27T19:04:23.946Z","categories":["56d1f33900a2a70b00b3658f","56d1f33900a2a70b00b36590","56d1f33900a2a70b00b36591","56d1f33900a2a70b00b36592","56d1f33900a2a70b00b36593","56d1f33900a2a70b00b36594","56d1f33900a2a70b00b36595","56d1f33900a2a70b00b36596","56d1f33900a2a70b00b36597","56d1f33900a2a70b00b36598","56d1f33900a2a70b00b36599","56d1f33900a2a70b00b3659a","571f9497ada30c34003b7cee"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"beta","version_clean":"2.0.0-beta","version":"2.0.0-beta"},"__v":1,"category":{"_id":"56d1f33900a2a70b00b36596","__v":1,"project":"5526c95cf69851170038b48f","pages":["56d1f33d00a2a70b00b365df","56d1f33d00a2a70b00b365e0","56d1f33d00a2a70b00b365e1","56d1f33d00a2a70b00b365e2"],"version":"56d1f33700a2a70b00b3658e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-10-12T20:12:57.656Z","from_sync":false,"order":6,"slug":"ionic-package","title":"Ionic Package"},"project":"5526c95cf69851170038b48f","user":"5564b8233b87582b003ab99b","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-10-05T21:49:01.226Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"This guide outlines what you can do with Ionic Package in the CLI. Let's start by building your app.\n\n\n\n## Your First Build\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Update the CLI\",\n  \"body\": \"Make sure you have the latest version of the Ionic CLI. You can update the CLI simply by reinstalling with npm: `npm i -g ionic`.\"\n}\n[/block]\nWithin your app directory, kick off an Android build in the Package service with the following command:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"ionic package build android\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\nSending your app's files to Package may take a minute. After the Package service receives your app, it will be queued and then built, which can take several minutes.\n[block:api-header]\n{\n  \"type\": \"basic\"\n}\n[/block]\n## Listing Builds\n\nYou can check the status of your builds with the following command:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"ionic package list\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Note\",\n  \"body\": \"As of now, there is no notification that your app has been built successfully. In the future, we hope to add email notification options and callback URLs when builds finish.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"\"\n}\n[/block]\n## Build Failures\n\nIf a build fails, you can determine the cause by getting a detailed report of a specific build by its ID.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"ionic package info 1\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Not my fault!\",\n  \"body\": \"Usually, builds fail due to misconfiguration. If it appears to be a bug in the Package service, please report it in our [Gitter channel](https://gitter.im/driftyco/ionic-io-testers) or the [Github issues](https://github.com/driftyco/ionic-io-issues/issues) for the Ionic Platform.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\"\n}\n[/block]\n## Downloading your Build\n\nBuilds can be downloaded by their IDs. This will download the Android APK or iOS IPA file, which you can then install on the appropriate device(s).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"ionic package download 1\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\"\n}\n[/block]\n## Building with Security Profiles\n\niOS builds require an iOS certificate and provisioning profile. Android release builds require a valid keystore. The Package service uses security profiles to manage these credentials.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Security Profile Required\",\n  \"body\": \"If you don't have a security profile set up for your app, head on over to the [Security Profiles](doc:security-profiles) documentation.\"\n}\n[/block]\nBuilding with a security profile is as simple as referencing which set of credentials to use. Just make sure you have the appropriate credentials set up for the target platform. It makes sense to have one security profile for *debug* mode and one for *release* mode, but you can have others that target other devices, too.\n\nYou can do an iOS debug build by referencing the tag of your security profile, like this:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"ionic package build ios --profile my_debug_profile\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\nTo do releases, just build with the `--release` option:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"ionic package build android --release --profile my_release_profile\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Enterprise certificates\",\n  \"body\": \"Please note that if you're building with an enterprise certificate using Ionic Package, you're going to need to use the `--release` flag for every build.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"CLI Usage\",\n  \"body\": \"For full usage of the package command in the Ionic CLI, type `ionic help package`.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Advanced Usage\"\n}\n[/block]\n## Cordova Hooks\n\nIonic Package does not yet support custom hooks. In the meantime, you can look at our [repository of common hooks](https://github.com/driftyco/ionic-package-hooks). These hooks are common within the Ionic/Cordova community and should suit most needs, such as re-enabling HTTP on iOS9, disabling bitcode during iOS builds, etc.\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Please contribute\",\n  \"body\": \"The repository of [Ionic Package Hooks](https://github.com/driftyco/ionic-package-hooks) is very new. If you think a hook belongs in there, please submit a pull request with author information. See [CONTRIBUTING.md](https://github.com/driftyco/ionic-package-hooks/blob/master/CONTRIBUTING.md#contributing) for more details.\"\n}\n[/block]\n## Platform Version\n\nYou can specifically set which `cordova-ios` and `cordova-android` version to use in Ionic Package. For example, if you don't want to use `cordova-ios` 4.x, you can ensure you're using 3.9.2 locally and in Ionic Package by doing the following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ ionic platform rm ios\\n$ ionic platform add ios:::at:::3.9.2\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Details, Details, Details\",\n  \"body\": \"Ionic Package reads `cordovaPlugins` and `cordovaPlatforms` from your `package.json` file in order to install the correct plugins and platform needed to build your app. You can tweak your local plugin and platform versions locally and then execute `ionic state save` to update your `package.json`.\"\n}\n[/block]","excerpt":"","slug":"package-usage","type":"basic","title":"Usage"}
This guide outlines what you can do with Ionic Package in the CLI. Let's start by building your app. ## Your First Build [block:callout] { "type": "warning", "title": "Update the CLI", "body": "Make sure you have the latest version of the Ionic CLI. You can update the CLI simply by reinstalling with npm: `npm i -g ionic`." } [/block] Within your app directory, kick off an Android build in the Package service with the following command: [block:code] { "codes": [ { "code": "ionic package build android", "language": "shell" } ] } [/block] Sending your app's files to Package may take a minute. After the Package service receives your app, it will be queued and then built, which can take several minutes. [block:api-header] { "type": "basic" } [/block] ## Listing Builds You can check the status of your builds with the following command: [block:code] { "codes": [ { "code": "ionic package list", "language": "shell" } ] } [/block] [block:callout] { "type": "info", "title": "Note", "body": "As of now, there is no notification that your app has been built successfully. In the future, we hope to add email notification options and callback URLs when builds finish." } [/block] [block:api-header] { "type": "basic", "title": "" } [/block] ## Build Failures If a build fails, you can determine the cause by getting a detailed report of a specific build by its ID. [block:code] { "codes": [ { "code": "ionic package info 1", "language": "shell" } ] } [/block] [block:callout] { "type": "info", "title": "Not my fault!", "body": "Usually, builds fail due to misconfiguration. If it appears to be a bug in the Package service, please report it in our [Gitter channel](https://gitter.im/driftyco/ionic-io-testers) or the [Github issues](https://github.com/driftyco/ionic-io-issues/issues) for the Ionic Platform." } [/block] [block:api-header] { "type": "basic" } [/block] ## Downloading your Build Builds can be downloaded by their IDs. This will download the Android APK or iOS IPA file, which you can then install on the appropriate device(s). [block:code] { "codes": [ { "code": "ionic package download 1", "language": "shell" } ] } [/block] [block:api-header] { "type": "basic" } [/block] ## Building with Security Profiles iOS builds require an iOS certificate and provisioning profile. Android release builds require a valid keystore. The Package service uses security profiles to manage these credentials. [block:callout] { "type": "warning", "title": "Security Profile Required", "body": "If you don't have a security profile set up for your app, head on over to the [Security Profiles](doc:security-profiles) documentation." } [/block] Building with a security profile is as simple as referencing which set of credentials to use. Just make sure you have the appropriate credentials set up for the target platform. It makes sense to have one security profile for *debug* mode and one for *release* mode, but you can have others that target other devices, too. You can do an iOS debug build by referencing the tag of your security profile, like this: [block:code] { "codes": [ { "code": "ionic package build ios --profile my_debug_profile", "language": "shell" } ] } [/block] To do releases, just build with the `--release` option: [block:code] { "codes": [ { "code": "ionic package build android --release --profile my_release_profile", "language": "text" } ] } [/block] [block:callout] { "type": "warning", "title": "Enterprise certificates", "body": "Please note that if you're building with an enterprise certificate using Ionic Package, you're going to need to use the `--release` flag for every build." } [/block] [block:api-header] { "type": "basic" } [/block] [block:callout] { "type": "info", "title": "CLI Usage", "body": "For full usage of the package command in the Ionic CLI, type `ionic help package`." } [/block] [block:api-header] { "type": "basic", "title": "Advanced Usage" } [/block] ## Cordova Hooks Ionic Package does not yet support custom hooks. In the meantime, you can look at our [repository of common hooks](https://github.com/driftyco/ionic-package-hooks). These hooks are common within the Ionic/Cordova community and should suit most needs, such as re-enabling HTTP on iOS9, disabling bitcode during iOS builds, etc. [block:callout] { "type": "danger", "title": "Please contribute", "body": "The repository of [Ionic Package Hooks](https://github.com/driftyco/ionic-package-hooks) is very new. If you think a hook belongs in there, please submit a pull request with author information. See [CONTRIBUTING.md](https://github.com/driftyco/ionic-package-hooks/blob/master/CONTRIBUTING.md#contributing) for more details." } [/block] ## Platform Version You can specifically set which `cordova-ios` and `cordova-android` version to use in Ionic Package. For example, if you don't want to use `cordova-ios` 4.x, you can ensure you're using 3.9.2 locally and in Ionic Package by doing the following: [block:code] { "codes": [ { "code": "$ ionic platform rm ios\n$ ionic platform add ios@3.9.2", "language": "shell" } ] } [/block] [block:callout] { "type": "info", "title": "Details, Details, Details", "body": "Ionic Package reads `cordovaPlugins` and `cordovaPlatforms` from your `package.json` file in order to install the correct plugins and platform needed to build your app. You can tweak your local plugin and platform versions locally and then execute `ionic state save` to update your `package.json`." } [/block]