Prepare Native build

Before being able to build on device (Android & iOS) we need to make sure your machine is ready for it.

This documentation should be sufficient to have Android and iOS ready to build but in case you are not successful, please read this more detailed documentation: http://ionicframework.com/docs/intro/deploying/

Install Cordova platforms and plugins

npm run ionic:prepare

Generate the Splashcreens and Icons

npm run ionic:resources

Android Devices

Requirements

Running Your App

To run your app, all you have to do is enable USB debugging and Developer Mode on your Android device, then run npm run run:android from the command line.

This will produce a debug build of your app, both in terms of Android and Ionic's code

Enabling USB debugging and Developer Mode can vary between devices, but is easy to look up with a Google search. You can also check out Enabling On-device Developer Options :https://developer.android.com/studio/run/device.html#developer-device-optionsin the Android docs.

More info: https://github.com/ionic-team/ionic-site/blob/7998473326c28d478f4264f14c9c7e963f588c9c/content/docs/intro/deploying/index.md

iOS Devices

Unlike Android, iOS developers need to generate a provisioning profile to code sign their apps for testing. The good news is that, as of iOS9, you can develop and test your apps on your iOS device without a paid Apple Developer account. This is particularly great for developers who want to try out mobile development with Ionic, since it saves the cost but still provides a lot of the features of having a full Apple Developer account. For a full breakdown of the features included, check out Apple's docs: https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/SupportedCapabilities/SupportedCapabilities.html#//apple_ref/doc/uid/TP40012582-CH38-SW1

Requirements

Creating a Provisioning Profile

To start, you'll need to set up a provisioning profile to code sign your apps.

Using an Apple ID

  1. Open Xcode preferences (Xcode > Preferences...)

  2. Click the 'Accounts' tab

  3. Login with your Apple ID (+ > Add Apple ID...)

Once you've successfully logged in, a new 'Personal Team' with the role 'Free' will appear beneath your Apple ID.

Using an Apple Developer Account

Creating a provisioning profile with a paid Apple Developer account is a little bit more involved. For full instructions, check out Launching Your App on Devices: https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/LaunchingYourApponDevices/LaunchingYourApponDevices.html in the Apple Developer docs.

Running Your App

  1. Open the .xcodeproj file in platforms/ios/ in Xcode
  2. Connect your phone via USB and select it as the run target
  3. Click the play button in Xcode to try to run your app

Oops, code signing error! No problem.

Code Signing Your App

Next, you'll need to code sign your app. How you do this will depend on if you are running Xcode 8 or an earlier version.

Xcode 7 and Earlier

If you are running Xcode 7 or earlier, you'll get a code signing error that looks like this when you try to run the app:

Click the 'Fix Issue' button, then select your 'Personal Team' profile.

Xcode 8

If you are running Xcode 8, the code signing error will appear as a buildtime error, rather than as a pop-up:

To select the certificate to sign your app with, do the following:

  1. Go to the 'Project Editor' by clicking the name or your project in the 'Project Navigator'
  2. Select the 'General' section
  3. Select the team associate with your signing certificate from the 'Team' dropdown in the 'Signing' section

Trusting the Certificate

Once you've code signed your app, you should get a launch error that looks like this. On Xcode 7 and below you'll see this automatically. On Xcode 8 it will appear the next time you try to run the app:

To get past this, we have to tell our iOS device to trust the certificate we code signed our app with:

  1. Open the 'Settings' app on your iOS device

  2. Go to 'General > Device Management'. You'll see the email address associated with the Apple ID or Apple Developer account you used to code sign your app.

  3. Tap the email address

  4. Tap 'Trust <your_email>':

Running Your App

Now, go back to Xcode and hit that play button or run npm run run:ios from the command line to install and launch your app on your iOS device.

results matching ""

    No results matching ""