I just released an iPhone app update and certain features don't work when the app is updated. More specifically, a plist that I download and store in Documents isn't displayed.
This worked fine in the previous app version and works fine if the new version is downloaded directly from the App Store. If someone upgrades, then uninstalls and reinstalls the app, that works too.
Does anyone know what's going on here? Apparently the app upgrade process completely replaces the app bundle but keeps external files and settings (NSUserdefaults, etc.).
More importantly, does anyone know how to fix this? My last resort is contacting my substantial user base and telling them to uninstall and reinstall, which is bad for my reputation.
Any help is appreciated!
It may be possible to write some code that checks the plist in the document folder against the plist in your bundle and then move the new plist to the documents folder, or at least updates the old key-values to your new key-values.
This is the way that preset Core Data stores are initialised.
Related
I'm making my first iOS app. And I have a question.In my app I want to save the current state of the app: levels completed, score reached, money, in-App purchases, etc. in a Settings.plist. The problem is, how can I place this plist so that if the user updates the app, he/she not to lose these settings. I read about The app sandbox, but I don't understand
how it works, and how can I manage that from Xcode.
You should store these settings in the NSUserDefaults. They are kept when new app versions are installed, so you won't have any problems.
Two points:
a) When you update your app after its in the app store by submitting a new version of the same app the files created by the old version will not be lost. So you can store whatever you like in the app's Document or Library directories and expect it to still be there after an update. The Library/Caches directory will not be backed up or restored by iTunes so don't put anything there that you can't re-create. If you submit a different version of the app (not an update but a new app, so you have two separate apps in the app store, perhaps free and paid) there is no way that I know of for the new version to get to the files that the first version created.
b) It's easy for the user to read, delete, or change whatever files you create in Documents/ or Library/. It can be done with an app on his/her Mac such as iExplorer (downloadable from macroplant.com). So be aware that if the file is human-readable, which a .plist file is, the user can change it to improve his/her score, get more consumables, or whatever. You can prevent that by encrypting the data, or somehow obscuring the meaning, or by some kind of checksum scheme so you can at least detect that it was changed. Any of those measures involve complications of course and may not be worth the trouble.
BTW... if you're developing an app that uses data files iExplorer is a great debugging tool. I have no vested interest in it except that I've learned how to use it and want it to continue to be supported. There are probably other apps that do the same thing but this one works great and is fast and easy to use.
I created an app for iOS 3.2 for the first version 1.0.
Recently I created an updated app for iOS 4.2 with print feature etc. for the second version.
My problem is that, the users are not able to update the app from appstore.
They are facing issues like data loss of version 1.0 app, crashing etc.
Can someone explain me what can be the reason for this?
And, how can I test this thing on my device, as I am not having the version 1.0 app from appstore, but the code for both versions.
Delete your new one on your test device and install the old one. Then build and debug the new one line by line. I had lots of trouble my first time through due to confusion over the update/migration process of core data. If you use core data, chances are your existing customers have an out of date store DB that your new code is crashing on. The store doesn't get wiped in an update if it's in your user's document directory... Only the one in the app bundle. You'll need to handle that reset or tell core data to migrate it to the new model. Of course, all this is speculation since you've given almost no details about the problem, frameworks used, log files, etc.
During a normal install process, data should not be overwritten. NSUserDefaults and files should remain during an upgrade, as long as the user doesn't delete the app first. I assume the crashing occurs after the new version is installed?
I have an unlocalized shipping app which has foo.xib in the main project directory. In preparation for localization, I moved this to en.lproj/foo.xib. Now, when I build my app and install on my test device, it ends up using the stale old foo.nib which must be there from before (the installation process must not remove old files in the app's bundle). Deleting the app from the test device and re-installing fixes it -- but I don't want my existing customers to have to do that.
Some of these are coming from calls to UIViewController's -initWithNibName:bundle method (to which I'm currently passing nil for the nibBundle). I can probably create an NSBundle instance here which points at the correct localized directory. The others are specified in Info.plist or in the "NIB Name" section in interface builder and I don't see a way to specify a bundle for those.
It might just be easier to rename all my xibs to (e.g.) en.lproj/newfoo.xib, then I presume it will find the correct nib at runtime. (And I'll have to remember to never again use the old "foo.xib" name in a new version.) Is there a more clever solution here though? (Other than going back in time and starting with en.lproj directories from the beginning ;-)
Thanks!
-Mike
Answering my own question in case anyone else runs into this issue. It appears that this is an artifact of the Xcode build-publish cycle, and it isn't a problem when user's upgrade via the App Store. I went ahead and published my update and no one has noticed problems that would result from stale resources.
As a speedup to development, it appears that Xcode only copies over resources that it detects have changed when you build and install to the simulator or a test device. (To prevent a game with 500MB of resources from having to be re-copied each and every time you build and test.) When you (re)move a resource from a project though, it does not detect this and (re)move the old copy. I will file a bug with Apple about it.
However, the App store does appear to do a clean install with each upgrade (copying over the user's documents directory) so this is not a problem from the App Store. I'm not sure if it is a problem when emailing beta testers an .ipa file or not.
I'm having the same issue. The problem is that the phone keeps a cache of the nibs. Somehow thus cache needs to be cleared for you to see the new localized nibs. I also don't want my users to have to delete the app since it stores data.
I just had the same issue but found a solution which works, even with Xcode's deployment quirkiness: Prevent UIViewController loading stale XIB from app bundle
I know it should persist if my Core Data Model has not changed, but how safe it is ?
I'm an inhouse developer and we have 20 iPods with some information there, entered by our users. Now there's some bug that this info can't be exported, so we have to install a new update and export that information.
We are not going to change the Core Data Model, just some routines for export, so the NSPersistentStoreCoordinator should be the same ...
We are going to pack the app and install the updates from iTunes, this will be ok and the data will be there ?????
thanks,
r.
edit:
so, the iPods were synchronaized with other iTunes, now if I want to update the app that it's there, iTunes says that is going to delete ALL applications and their DATA, and the computer that installed them is not working now ...
so , how I can install a corrected version without losing the data ?????
thanks!
r.
If you have followed practice shown in template generated iPhone apps and copied (or created) your data in the apps Documents folder - then yes, it will still be there when you update from the App Store.
I am planning to post an application for iPhone in iTunes Store. Soon I am gonna provide an upgrade for it. But later to current version. I want to know how the upgrade system works in iPhone. Like does it replaces the whole application and reinstall it deleteing the previous database or it adds the new version keeping the database and all the same.
Upgrades replace the app bundle, but anything else in your sandbox (like the Documents folder, caches, preferences, etc) are preserved in place.