Ionic-cli: ionic repair does not properly re-add Cordova platforms in last step

Created on 7 Jun 2019  路  1Comment  路  Source: ionic-team/ionic-cli

Description:

When using the ionic repair command on a project which has previously had Cordova platforms added to it, everything works until the very last step (when the command attempts to re-add the platforms with cordova prepare). The end result is that Cordova platforms are not automatically added back to the project and need to be manually added again by running ionic cordova platform add <platform>.

Steps to Reproduce:

  1. Start a new Ionic project using ionic start CordovaApp blank
  2. cd to the project directory after the app is created
  3. (Optional) To ensure a built www directory is included, run ionic build
  4. Add cordova-android and/or cordova-ios to your project using one or both of the following commands:
  5. ionic cordova platform add android
  6. ionic cordova platform add ios
  7. The platforms are added to your project
  8. Run ionic repair
  9. Notice that the final step of the repair command fails to re-add your platforms

Output:

Screen Shot 2019-06-07 at 8 06 58 AM

My ionic info:

Ionic:

   Ionic CLI                     : 5.0.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.4.2
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   Cordova CLI       : 9.0.3 ([email protected])
   Cordova Platforms : none
   Cordova Plugins   : no whitelisted plugins (0 plugins total)

Utility:

   cordova-res : not installed
   native-run  : 0.2.3

System:

   Android SDK Tools : 26.1.1 (/Users/bryantplano/Library/Android/sdk)
   ios-deploy        : 2.0.0
   ios-sim           : 8.0.1
   NodeJS            : v10.16.0 (/usr/local/bin/node)
   npm               : 6.9.0
   OS                : macOS Mojave
   Xcode             : Xcode 10.2.1 Build version 10E1001

Other Information:

Previously mentioned that this commit might fix the issue, but that doesn't appear to be the case: https://github.com/ionic-team/ionic-cli/commit/d9e1cedaffcd298f968993a3c9d3a6ffeb93b870

It looks like package.json and config.xml both have references to the platforms, but they aren't checked by the CLI. Could be a quick fix, just need to check for the platforms in one (or either) of those files?

config.xml

    <platform name="android">
...
    </platform>
    <platform name="ios">

package.json

    "cordova-android": "8.0.0",
    "cordova-ios": "5.0.1",
bug cordova

Most helpful comment

This is because Cordova 9 no longer manages platform & plugin versions in config.xml, only package.json. The fix will require reading and preferring package.json as the source of "which platforms are installed".

>All comments

This is because Cordova 9 no longer manages platform & plugin versions in config.xml, only package.json. The fix will require reading and preferring package.json as the source of "which platforms are installed".

Was this page helpful?
0 / 5 - 0 ratings