On App update custom plist file will get updated or do we need to do some thing? - iphone

I have an app in appstore now im going to push out an update of app, Im having a custom Plist file with set of values in my application bundle, and these values are been modified from the version which is in production and in addition even more key value pairs are added in to this file.
Now my doubt is on updating this app to appStore will the update process automatically overrides(updates) my new plist file on top of existing one or do we need to do some work around like how we do for database changes like coredata migration and all?

As explained here: iOS App Programming Guide, this is what happens when you update an app:
Files Saved During App Updates
When a user downloads an app update,
iTunes installs the update in a new app directory. It then moves the
user’s data files from the old installation over to the new app
directory before deleting the old installation. Files in the following
directories are guaranteed to be preserved during the update process:
Application_Home/Documents
Application_Home/Library
Although files
in other user directories may also be moved over, you should not rely
on them being present after an update.
This means that all the resources that were in your bundle will be "lost" and you will have the new ones from your new bundle. If you were using this plist file for read only purposes this won't be a problem, if you were saving some user preference on this file, i'm afraid that these user information will be lost. You should save this kind of data in the documents directory, always!

When the update is deployed it will overwrite existing plist files.

When you update your app on App store it replaces new binary with old binary. So with binary it also replaces your plist too. So don't worry about that, just be aware that your info in app store details and details in plist should be same otherwise it will not take your binary file for app version update.

Related

Write a File into the App Bundle

I have a Webservice to download some News and write them into a plist-file somewhere in NSLibraryDirectory, thats fine. But if the user has no Internet connection or the webservice is offline or whatever, I load a Default-Newsfile from within the AppBundle.
At the moment I have to replace the Default-File manually before every AppStoreUpdate to keep it up to date.
My Question: Is there an easy way to write into the App Bundle while debugging via Simulator, so the Default-File will everytime be up to date.
I tought about something like:
#ifdef SIMULATOR
//Write to AppBundle
#endif
Note:
It's all about the time while I use the Mac and the Simulator, I don't want to do that in the Published App!
Yes, I already replace the Ressource in my Bundle, but by hand and I want it to realize automatically.
I want to keep my Projectfolder up to date, before I compile it for any Device or the AppStore.
AppBundle is Read-only you cannot write anything to it programmatically, however if you update the resources in your Project through Xcode, you get the updated file automatically in the AppBundle..
Ok, based on your comment, here's what you need (I think - still not completely clear on the question, but let me know if this works for you).
Create an empty file (say news.plist) in your project folder (SRCROOT). Add this to your repo.
Add this file in your project's resources and add it in Copy Bundle Resources step in Build Phases
When you download content from internet, save it to project's temporary folder, then copy it to SRCROOT/news.plist overwriting existing file (optionally add a check on file checksum to avoid unnecessary change). This step is required ONLY when running on simulator.
Whenever developers check-in, the updated news.plist should be checked in to the repo.
To make SRCROOT available in code, add SRCROOT=\"${SRCROOT}\" to GCC_PREPROCESSOR_DEFINITIONS.
Other developer won't need to do anything except the last step - check in the updated file every time it changes.
Does this help?
No, you might be possible to get the simulator to write to you App Bundle, but this does not mean that the file your project (the one that gets compiled when you build for the app store) will be updated.
Why not just save the new to the documents directory, then always load this file. After the app is started, start a background thread and try to update the plist file. Of you are successful in retrieving the news over the write the plist file in the document directory.
This way the user will have an file that was retrieved the last time the device was able to get the file.
You could add an file in the app bundle which you copy to the documents directory on first start of the application, just to make sure that the user has data in the app.

Does apple delete core data on the app update from itunes?

I am using sqlite in the first version of my app to store some data, now I have to change the structure for some tables.
Note that I released new version before and notice that the database was deleted after update since I did not see the database records after update and it start registering rows again.
My question is do I need to handle the tables deletion on update, and why apple delete the tables in the previous update?
It depends on the name of your database file, table name and the location.
From Apple's programming guide:
When a user downloads an app update, iTunes installs the update in a new app directory. It then moves the user’s data files from the old installation over to the new app directory before deleting the old installation. Files in the following directories are guaranteed to be preserved during the update process:
<Application_Home>/Documents
<Application_Home>/Library
Although files in other user directories may also be moved over, you should not rely on them being present after an update.
Reference: http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/PerformanceTuning/PerformanceTuning.html
There are several possible reasons why you did not see any data after the update. For example, the code in your second update could have changed the name of the database file, or the names of certain tables or fields.
In principle, the old sqlite store should be present after the update.
You will have to code the migration manually: on first launch after the update, create a new store, read every record from the old store and save it with the new format in the new store.

My recently posted app update doesn't have latest/correct values in the info.plist file

I have a part in my info.plist file that stores a key metric that the app uses to know how many db's it can expect to load. It is a simple number that I change as needed. For some reason, when the app updates from the App Store with new values, it is as if the updated plist values aren't there. The app is working based on the old values.
But if I remove the application completely, and then reinstall from the App Store, it works! What am I missing here? Why wouldn't the plist file be updating correctly with an update? Is there some sort of manual copy/update process I should be doing to the Documents directory or something?
Can you write code of how you are accessing data from info.plist.
Also, remember when you are storing any data in documents directory, it will not update until you make it forcefully.
And info.plist always gets update once you update you build.
Hope it helps....

Newsstand App Storage

I have developed one app in which, monthly magazine issues are downloaded and stored inside the app Document directory.
But app have rejected app due to storing of magazine issue in document directory. My magazine file size is around 50 MB.
They mentioned below:
The iOS Data Storage Guidelines indicate that only content that the user creates using your app, e.g., documents, new files, edits, etc., may be stored in the /Documents directory - and backed up by iCloud.
Temporary files used by your app should only be stored in the /tmp directory; please remember to delete the files stored in this location when the user exits the app.
Data that can be recreated but must persist for proper functioning of your app - or because customers expect it to be available for offline use - should be marked with the "do not back up" attribute. For NSURL objects, add the NSURLIsExcludedFromBackupKey attribute to prevent the corresponding file from being backed up. For CFURLRef objects, use the corresponding kCFURLIsExcludedFromBackupKey attribute.
Any help appreciate.
Thanks.
Move your files to the Caches directory and you should be good to go.
I believe that if it is user generated content, there is no problem with storing it on the /Documents folder.
Since it is content that can be downloaded again, you have to set the NSURLIsExcludedFromBackupKey file attribute which prevents it from being backed up to iCloud.
Take a look at this question on setting the attribute: Use NSURLIsExcludedFromBackupKey without crashing on iOS 5.0

Shipping Documents Items with an iPhone App

My iPhone app uses a small database to store its settings and saved files. How can I ensure that the default database, with its default settings, gets distributed to anyone who downloads it along with the application files?
EDIT Sorry, I was in a rush when I posted this. I forgot to mention that the database needs to end up in the 'Documents' folder of the application so that it can be backed up at a later date by the user.
-Ash
Put it in "Resources". Then on your first launch, you'll need to load that file out of your mainBundle and save it to the Documents directory. The file will "come with" the app, but it won't live in the right place to get caught by backup.
A side-effect is that restoring the app to factory settings is as easy as deleting that file. Next launch, you can see you don't have your file, and copy a fresh one out of your bundle.
You include it as a file in the Resources folder of your application.