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:
ionic start CordovaApp blank
cd
to the project directory after the app is createdwww
directory is included, run ionic build
cordova-android
and/or cordova-ios
to your project using one or both of the following commands:ionic cordova platform add android
ionic cordova platform add ios
ionic repair
repair
command fails to re-add your platformsOutput:
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",
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".
Most helpful comment
This is because Cordova 9 no longer manages platform & plugin versions in
config.xml
, onlypackage.json
. The fix will require reading and preferringpackage.json
as the source of "which platforms are installed".