Skip to main content

Loading the code in a platform - in this article, I'll be focusing on Android and iOS.  Ionic app shell prompts for iOS and Android devices.

iOS

npm run build
npx cap sync
npx cap copy ios
npx cap open ios

 

Android

npm run build
npx cap sync
npx cap copy android
npx cap open android

 

Chained commands

iOS

npm run build && npx cap sync && npx cap copy ios && npx cap open ios

Android

npm run build && npx cap sync && npx cap copy android && npx cap open android

 

If doing both, best to separate them into two primary zones

Set up for either Android or iOS

npm run build && npx cap sync

Then add the corresponding platform

iOS

npx cap copy ios && npx cap open ios

Android

npx cap copy android && npx cap open android

 

Breaking down the steps

npm run build

This command will do custom work written inside package.json.  It lets you perform any necessary building/prep tasks for your project.

"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
},

npx cap sync

This command runs npx cap copy and npx cap update.  This action will copy all the change to {platform}/app/src/main/assets/public, ensure the android and ios platform have the same conditions.

npx cap copy

This command copies what's in your webDir to the native platforms like Android and iOS.  If you have Cordova files they will also be copied.

npx cap update

Searches for Cordova and Capacitor plugins and copy/update some native files the plugins need for working.

So copy is for "web" files and update for "native" files and sync does both.

npx cap open iOS / android

Open's the project in the native software such as Xcode / Android Studio.

 

Related articles

Andrew Fletcher21 Sep 2022
Android Studio error when running app through emulator
Only a month ago, running an app through the Android Studio emulator was running fine.  Now I'm warmly greeted by Error Installation did not succeed. The application could not be installed: INSTALL_PARSE_FAILED_NO_CERTIFICATES The complete error is  Launching '{project}' on...
Andrew Fletcher22 Aug 2022
Android releasing app issues
Warning from Google Play Store when uploading an App You must complete the advertising ID declaration before you can release an app that targets Android 13 (API 33). We'll use this declaration to provide safeguards in Play Console to accommodate changes to advertising ID in Android 13. Apps...
Andrew Fletcher22 Aug 2022
Version code 1 has already been used. Try another version code
Uploading a new version of an Android app to Google Play and I'm seeing this error Version code 1 has already been used. Try another version code. There are three areas to observe: Version Code: {whole integer} Version Name: {String} Version Name Suffix: {Integer} Currently, my...