rebuilding on ios creates a Suspend issue

This is a weird problem that I do not understand. 

When I delete my app and reinstall, it runs fine.  When I run the app, then make changes and rebuild, then reinstall without deleting, I get errors where my variables have nil values and the app crashes.  

I am trying to go through the variables and make sure they are reinitialized with the values that were present before suspend - but I am chasing my tail on this… there always seems to be another ‘nil’ value somewhere.

I would hate to release an update that crashes the app for my users - has anyone seen this before? Is there something I can do to make a clean update work with the previously played version? Why doesn’t the update force the app to start from the beginning?

I haven’t seen this issue anywhere else, so I am not sure what is causing it now.

Thanks!

Any ideas on how I can force the app to restart when a new version is installed?

On iOS (and Android) when you “update” an app, it keeps all of the contents of your system.DocumentsDirectory, system.ApplicationSupportDirectory, system.CachesDirectory and probably system.TemporaryDirectory.

If you do a delete and install, you start with empty directories.

Look at what you’re reading from your storage and make sure your new version knows how to read older files. I’ve seen people update their settings to need new values and when they read an old settings file, those values are not present and you get a bunch of nil errors.

You need to potentially store a version number to check, or at least check each variable that you load and see if it exists or not and if it doesn’t provide a reasonable default. Don’t make an assumption that just because you read a settings file successfully all is good to go. If you do need to set defaults on missing values, make sure to save the new version of the settings file back out.

Rob

Thanks Rob, 

Your comments made me realize that my real issue is that I am saving the lastScene on suspend and exit, so that I can come back into the app at the right place.  I don’t want this to happen if the app was updated between sessions, so I would like to check for something that will allow me to just restart the app if an update occurred.  That should allow the settings to load when needed, rather than trying to rescue them for the lastScreen after an update.

Is there anything I can look at in the system.getInfo or in the native libraries that indicates a recent install or update?  Or is this where I need to save the version or build in a setting?

Thanks for helping with this.

You probably should save a version #.

Rob

I think I got it worked out - at least I am not getting any errors on each build, so now I can focus on what I was really trying to update.

I save the build number and compare it against the current build value.  If ‘nil’ (previous versions where the build number was not saved) or less than the current build value, I know an update has occurred and I can start the app from the menu, rather than trying to go back to the last scene.  This seems to get the job done.

Thanks once again Rob.

Any ideas on how I can force the app to restart when a new version is installed?

On iOS (and Android) when you “update” an app, it keeps all of the contents of your system.DocumentsDirectory, system.ApplicationSupportDirectory, system.CachesDirectory and probably system.TemporaryDirectory.

If you do a delete and install, you start with empty directories.

Look at what you’re reading from your storage and make sure your new version knows how to read older files. I’ve seen people update their settings to need new values and when they read an old settings file, those values are not present and you get a bunch of nil errors.

You need to potentially store a version number to check, or at least check each variable that you load and see if it exists or not and if it doesn’t provide a reasonable default. Don’t make an assumption that just because you read a settings file successfully all is good to go. If you do need to set defaults on missing values, make sure to save the new version of the settings file back out.

Rob

Thanks Rob, 

Your comments made me realize that my real issue is that I am saving the lastScene on suspend and exit, so that I can come back into the app at the right place.  I don’t want this to happen if the app was updated between sessions, so I would like to check for something that will allow me to just restart the app if an update occurred.  That should allow the settings to load when needed, rather than trying to rescue them for the lastScreen after an update.

Is there anything I can look at in the system.getInfo or in the native libraries that indicates a recent install or update?  Or is this where I need to save the version or build in a setting?

Thanks for helping with this.

You probably should save a version #.

Rob

I think I got it worked out - at least I am not getting any errors on each build, so now I can focus on what I was really trying to update.

I save the build number and compare it against the current build value.  If ‘nil’ (previous versions where the build number was not saved) or less than the current build value, I know an update has occurred and I can start the app from the menu, rather than trying to go back to the last scene.  This seems to get the job done.

Thanks once again Rob.