Ionic deploy loads old snapshot (iOS)

Hi! I’ve integrated ionic live updates into my app recently.
Now I have a problem with snapshot version: app always loads old snapshot if I load new app version via Xcode or ionic-cli.
Only able to load new version by deleting app from device.

Xcode v. 8.3.3
Ionic v. 3.4.0 (with ionic-v1 app)
Cordova v. 7.0.1
ionic-plugin-deploy v.0.6.7

Steps to reproduce:

  • Install binary via xcode or ionic-cli run
  • make code changes and upload snapshot with “ionic upload --note “some note” --deploy dev” command
  • check for updates, download and extract snapshot ( $ionicDeploy.check(), download(), extract() )
  • do not apply snapshot at the moment
  • make some changes in the app
  • update binary via Xcode or ionic-cli run

Result: loaded old version from snapshot
Expected result: latest code changes should be reflected.
Also if I run “ionic run ios --device --livereload” code changes not reflected. It worked perfectly before implementing deploy.

Additional info:
Livereload partially works - if I close app manually and start it again - I can see changes. But it still won’t reload automatically on changes and no console output (running with “ionic run ios -l -c -s”)

Sorry, I don’t follow.

Can you please elaborate what you do step by step, include the ionic upload command, when you deploy in apps.ionic.io etc. - more details are needed to understand and then fix your problem. (Giving the “versions” a “name” or “number” in the description usually helps, too)

(Also post your ionic info output for good measure)

Hi!

In other words: App still uses last deploy snapshot even after binary update.
I assume it just loads last snapshot ignoring current www directory content.

ionic info:

global packages:

@ionic/cli-utils : 1.4.0
Cordova CLI      : 7.0.1 
Gulp CLI         : CLI version 1.2.2 Local version 3.9.1
Ionic CLI        : 3.4.0

local packages:

@ionic/cli-plugin-cordova : 1.4.0
@ionic/cli-plugin-gulp    : 1.0.1
@ionic/cli-plugin-ionic1  : 2.0.0
Cordova Platforms         : android 6.1.2 ios 4.4.0
Ionic Framework           : ionic1 1.3.3

System:

Node       : v7.2.1
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b 
ios-deploy : 1.9.0 
ios-sim    : 5.0.13 
npm        : 4.3.0 

deploy command (as I mentioned above):
ionic upload --note “new note” --deploy dev
:heavy_check_mark: Retrieving deploy channel - done!
:heavy_check_mark: Requesting snapshot upload - done!
:heavy_check_mark: Uploading snapshot - done!
[OK] Uploaded snapshot abdb561f-74ce-4700-b71a-cbaa93acd21d!

Sequence in app (called manually, no automatic deploys):
$ionicDeploy.check() //returns true
$ionicDeploy.download() // download ok
$ionicDeploy.extract() // extract ok

After successful deploy app always uses last snapshot. I still able to push updates via deploy, but binary updates totally ignores changes in JS files.

I didn’t set Equivalent, Minimum or Maximum version in web interface, but I only checking for updates manually, so it can’t overwrite last binary update after launch.

Sorry, I still don’t understand the chronological order and e.g. what you mean by [quote=“allforfree, post:1, topic:96713”]
update binary via Xcode or ionic-cli run
[/quote].

Please write a chronological order of events that break things for you.

Under binary update I mean for example command:
ionic cordova run ios --device
Same result can be achieved by installing updated version via testflight or from App Store.

For testing purposes I’ve implemented version constant into app.js.
Below chronological order with constant output.

  1. Install binary. Success. Installed version: 0.2.1
  2. Make changes in app.js. Set version to 0.2.2
  3. Update via deploy - success. Got version 0.2.2 - works as expected.
  4. Make changes in app.js Set version to 0.3.1
  5. Binary update - success. But version is still 0.2.2
  6. Delete app from device.
  7. Install binary. Success. Version: 0.3.1 - expected same result on step 4.

How can I make binary update to last version without deleting app from device?

Ok, this makes sense so far.

Some clarifying questions:

Where is version set to 0.2.1 exactly?[quote=“allforfree, post:6, topic:96713”]
2) … Set version to 0.2.2
[/quote]

Where do you change this to 0.2.2?[quote=“allforfree, post:6, topic:96713”]
3) Update via deploy
[/quote]

Means executing ionic upload and then setting the version as active at apps.ionic.io, correct?

What exactly do you do here?

How exactly do you install this binary? Which command were run in between on the CLI?

It’s just a constant named version in the app.js file. config.xml remains the same all the way.
Lets call it app.js file version.

Same. Constant in app.js

Not exactly, but close to. Means executing
ionic upload --note "note" --deploy dev command from ionic-cli.
But I think we’ll get same result by setting active snapshot at apps.ionic.io

ionic cordova run ios --device because it’s faster.
Or I can load Xcode ant click “Run”, or I can upload new archive into testflight - same result.

Same. Run command from ionic-cli:
ionic cordova run ios --device
No commands between. Only difference that app was deleted from the device between steps 5 and 7. Deleted using touchscreen on the device, no commands.

Right, I forgot about that.

I am asking so specific to understand when and how your app where you edit files makes the move from your project directory to the copy of www inside the platforms folders which is used to build. Could it be that this doesn’t actually happen between steps 4 and 5 but between steps 6 and 7? (I am not that fluent with Ionic v1 any more… with Ionic v2+ you would have to somewhere trigger a build from src to www that would then be used with run)

Alternative thought: Are you sure the binary is replaced at 5)? Maybe the device sees that it is the same binary version (from config.xml) and doesn’t change the file then? As you still see 0.2.2 in 5) this could somehow be the case…

I’ve done some additional checks.

  1. Fresh app installation, never updated via deploy. Updates with cordova run command, version changes as expected every time. After first deploy version remains the same as in last snapshot.
  2. changed app version in config.xml and constant in app.js. App version in iOS “Manage Storage” screen changed to new version as I set in config.xml. Constant in app.js remains same as in unmodified version from deploy snapshot.

It compiles during cordova run command. Verified with check n.1

Verified with check n.2

A thought:

This version is not available via Ionic Deploy, right?
Is it possible the app downloads this verison on start again in step 5 after the binary update?

Just to clarify: You are using ionic cordova run, not cordova run directly, right?

Right.

Not possible. I only call deploy update manually. I also checked in flight mode without internet - same result. It definitely uses snapshot version from previous deploy update, not downloading it again.

Update: one more check. I’ve changed active deploy version on apps.ionic.io to very old version. Launched version from last deploy. Version downgrades only after I run deploy manually from the app.
So there is no hidden automatic deploys.

What happens if you in step 5) also update the real app version via config.xml? (Or did you already test that?)

As I already answered - app version in iOS information changes, but app still uses old JS files. So it didn’t help. But this way we can know that binary really updated.

1 Like

Ok, then something is very wrong or strange here: When the binary is updated, really exchanged on the device, also the www content is replaced.

Only thing I can now thing of is that the unpackaged snapshots of Deploy stay on the device, so when the new app starts it again loads this snapshot from before. Only by uninstalling the app, you remove the unpackaged, previously used snapshots and then get a the correct www from inside the ipa.

Ok, that acutally makes sense, doesn’t it?

To test this you would have to install the binary from 1) with 0.2.1 in step 5) again - can you test that? It will probably still be 0.2.2 after that - which also makes sense as the “normal” use case for Ionic Deploy would probably be that you make multiple snap shots, then only the app you uploaded to the store a week ago gets released with a new binary but the now obsolete www - and you don’t want to go back to that old version from the store but stay on the already deployed snapshot. Right?

Yes, www content is replaced on binary update, but snapshot remains on device. And app launches scripts from old snapshot, not from updated www folder.

I’ve tested it several times - if no snapshots present, it uses script from www. Otherwise it loads scripts from snapshot ignoring updated www folder which comes with new binary.

I don’t think that such behaviour is normal use case: Imagine that somebody accidentally have deployed broken snapshot(parse error in js, or smth like this). App is dead from this moment. You can’t update it via deploy, because it’s broken and won’t launch deploy check. And even App Store update can’t fix it because app will load broken script from snapshot.

You probably shouldn’t deploy broken snapshots then :wink:

Yes, you are probably right. Maybe there is another way to handle that?
Setting a max version for the “broken” build lower than the one you are updating to might work.

This way it works! Thanks!

Setting max version BEFORE deploying snapshot and then changing app version in config.xml helps.
But if you are using ionic-cli deploy command it’s not possible to set max version in the cli. So snapshots deployed via cli command will never expire if somebody install it before you set max version on the website.

My suggestions:

ionic-cli ionic upload --deploy command should allow setting min, max and equivalent version of snapshot. Maybe it’s good idea to add command line option for setting max version to next minor version. E.g. your app version 0.2.14 and max snapshot version automatically sets to 0.3.0

Documentation of deploy service doesn’t contain information that your app will be rejected by Apple if you add update confirmation dialog to your app. Probably it should be mentioned.

More explanations required on this part of documents:


and should contain link to https://docs.ionic.io/api/client/deploy/ (only able to find it with google)

Pages
https://docs.ionic.io/api/client/deploydownloadoptions/ and https://docs.ionic.io/api/client/deployextractoptions/
can be merged into one and there is should be at least one example with note mentioning digest cycle only occurs after download ends. Due to lack of documentation I spent few hours trying to figure out how to make working progress indicator.

Also a good idea to implement addition $ionicDeploy function for deletion all downloaded snapshots except active one. It’s very common use case, but for now developers must write their own implementations with recurring promise chains for deleting old snapshots from device.

See my issue from 2015 that suggests exactly this (and setting metadata, but this has been implemented a few weeks ago): Feature Request: `ionic upload` could be able to set versioning data for Ionic deploy · Issue #660 · ionic-team/ionic-cli · GitHub A +1 on the issue might help :wink:

All the others things you said are true, but Ionic Deploy itself hasn’t received updates for quite some time - I think Ionic might be working on an updated version of the service. See Where we're going with "Cloud" - Ionic Blog for that.

1 Like