ionic-team / ionic-cli

The Ionic command-line interface
MIT License
1.99k stars 640 forks source link

Undocumented Breaking Change v6->v7: cordova-plugin-ionic #5053

Closed crossan007 closed 6 months ago

crossan007 commented 7 months ago

Description: I'm not 100% sure this is the correct location to file this bug; however, in the absence of clarity and search results, I'm proceeding here. Hopefully I have included enough keywords that anyone else experiencing this may find solutions.

The NPMJS package cordova-plugin-ionic provides access to the Deploy object for managing Ionic AppFlow Live Deploys; described in documentation at https://ionic.io/docs/appflow/tutorial/live_updates_api#preparing-the-home-page-to-use-live-update-api

This allows developers to provide a mechanism to end-users to manage / trigger live updates.

The list of Ionic CLI v7 breaking changes does not mention broken plugins.

Using @ionic/cli 6.20.9, the build steps for this package are executed, but in @ionci/cli 7.1.1, the build steps are not executed. This definitely affects Android target platform, and might affect ios targets.

This bug may manifest when choosing a different AppFlow build stack for instance, changing from 2023.04 to 2023.06. A (probably sub-optimal) workaround to using the latest build stack is simply to include the Ionic CLI as a devDependency in package.json: "@ionic/cli": "^6.20.9".

The plugin build steps in question are https://github.com/ionic-team/cordova-plugin-ionic/blob/main/plugin.xml#L52C18-L52C18 which appear to be responsible for writing configurations to android\app\src\main\res\values\strings.xml

Steps to Reproduce: Run ionic deploy add --app-id=default-value --channel-name=Production_5.0.0 --update-method=background

Output: Using CLI 6.x:, the following strings are present in android\app\src\main\res\values\strings.xml

<string name="ionic_app_id">default-value</string>
<string name="ionic_channel_name">Production_5.0.0</string>
<string name="ionic_update_method">background</string>
<string name="ionic_max_versions">2</string>
<string name="ionic_min_background_duration">30</string>
<string name="ionic_update_api">https://api.ionicjs.com</string>

Using CLI 7.x, these strings are absent from the strings.xml file, and a following npx cap sync command shows the following warning when run for ios platform (but not for android):

- update ios [warn] Configuration required for cordova-plugin-ionic.
       Add the following to Info.plist:
       <key>IonChannelName</key>
       <string>$CHANNEL_NAME</string>

[warn] Configuration required for cordova-plugin-ionic.
       Add the following to Info.plist:
       <key>IonAppId</key>
       <string>$APP_ID</string>

[warn] Configuration required for cordova-plugin-ionic.
       Add the following to Info.plist:
       <key>IonApi</key>
       <string>$UPDATE_API</string>

[warn] Configuration required for cordova-plugin-ionic.
       Add the following to Info.plist:
       <key>IonUpdateMethod</key>
       <string>$UPDATE_METHOD</string>

[warn] Configuration required for cordova-plugin-ionic.
       Add the following to Info.plist:
       <key>IonMaxVersions</key>
       <string>$MAX_STORE</string>

[warn] Configuration required for cordova-plugin-ionic.
       Add the following to Info.plist:
       <key>IonMinBackgroundDuration</key>
       <string>$MIN_BACKGROUND_DURATION</string>

Expected Behavior: The string values are present in android\app\src\main\res\values\strings.xml

Additional Info: To further complicate matters, the failure to populate strings.xml does not cause the build to completely fail; an APK file is still generated. With the missing strings, lots of runtime errors occur:

Most notably: VM4:2910 Uncaught (in promise) String resource ID #0x0

But also, it seems like the failure to load this plugin at runtime prevents lots of other application initialization:

VM4:2454 onscript loading complete
VM4:215 native App.addListener (#80369568)
VM4:2218 deviceready has not fired after 5 seconds.
VM4:2211 Channel not fired: onIonicProReady
main.d40ad6e7a1e12460.js:1  Ionic Native: deviceready did not fire within 5000ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.
(anonymous) @ main.d40ad6e7a1e12460.js:1
main.d40ad6e7a1e12460.js:1  Ionic Native: deviceready did not fire within 5000ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.

Possibly Related Issues/Threads:

jcesarmobile commented 6 months ago

You are linking Ionic Framework Breaking changes, those have nothing to do with Ionic CLI breaking changes. Ionic CLI breaking changes are documented here.

The remaining deploy commands have been renamed to live-update. So instead of running ionic deploy add you have to run ionic live-update add, it's properly documented on the first link you shared.

If you are using Capacitor, there is a new Capacitor plugin you can use instead of cordova-plugin-ionic, see https://ionic.io/docs/appflow/deploy/setup/capacitor-sdk

crossan007 commented 6 months ago

@jcesarmobile Thanks for the clarification! I was getting lost in the docs, so I appreciate it.