I have released version 1.0 of my app. Version 1.1 will likely include some kind of migration code. For argument’s sake, let’s say it will update a core data attribute – all last names will be converted to uppercase. I will execute this code on first launch in version 1.1.
Will I need to keep this code in place for all subsequent versions? If a user skips 1.0 and only updates when 1.2 is released, will 1.1 be applied first automatically? Or do I need to keep checking whether to update the last names in all versions forever?
You don’t release updates, you release new versions. If someone updates from 1.0 to 1.2 and skips 1.1, than that’s exactly what’s happening. 1.1 will never be installed or executed.
EDIT:
Here is a suggestion for a very simple way to manage updates. Probably not the most elegante one, but it works.
In this example you had 4 versions (1.0, 1.1, 1.2, 1.3) and 1.3 is the newest release.
You run this on every launch of your app. Since updating the app also terminates it, you can assume that this will run after a possible update.
Basically you load the last version that the user used on this device from the user defaults. If the app launches for the first time ever, there will be no known previous versions, none of the update routines are executed and the current version (1.3) is saved as the last used version.
If the app was used with the previous version (1.2), then
lastVersionwill be1.2and only the lastifblock is executed.If the app was used with version 1.1, but skipped 1.2 and was now updated to 1.3,
lastVersionwill be 1.1 and the last twoifblocks are executed sequentially. So first you update your data from 1.1 to 1.2, then from 1.2 to 1.3.