Changing resource file in new version of an app - iphone

I'm working on an update for an already existing iphone app. The existing version contains a .sql database file which is used in the app.
I would like to use a new version of this file in the update of the app. On the first startup of the existing app the .sql file is placed in the caches directory of the users iphone. From what I can understand from Apple's documentation the files in the caches directory might get copied from the old app to the new versions caches directory when the user updates the app.
Does this mean that for being sure my new file is used in the updated version I should use a different name of the file?
And what happens with the old file? Do I have to manually delete it from inside the app? Which means I have to check if it's there at every startup of the app?
Thanks
Michael

Yes, you could use a different name, or you could use the same name, and do an "upgrade" (delete and replace) on the first time the user uses a new version.
This does imply checking at every app start, but that's not a bad idea anyways. Having some code that checks versioning at app start lets you put any data upgrade stuff in one place.
One technique is to use NSUserDefaults to keep around two pieces of information: the originally installed version of the app, and the most recently run version of the app. You check these at startup. If they're not there, write both of them. If the most-recent version is lower than the running app version, run your upgrades and bump the version. You could use the first flag to know conditionally in other places whether to expect certain data to be sitting around or not. Having versioning stored explicitly lets you know which version you're upgrading from, too, which might not be obvious if the user hasn't downloaded say 5 intervening updates.

Related

How to make Custom Application to persist reboot of WinCE 6.0 OS?

I am looking for a solution on how to setup the Windows CE 6.0 design image to integrate my custom application.
I want after building the image and starting it on the target machine to be able
to access my application from the \Hard Disk\Program Files\CustomApp folder.
In addition I require the application to be persistent. It must not be lost after reboot.
I am aware of copying the application to the Hard Disk out of the NK.BIN but if is possible I want a solution like adding dlls or other files to Windows folder.
I am usign an SQL CE database along with the application so I want the data to be persistent too.
Thanks in advance.
If the \Hard Disk folder contents are not persistent (and I assume they aren't since you're asking this questions), then getting the app to "persist" can be done only as a slight-of-hand trick, just like the contents of the Windows Folder. At boot, the OS will get expanded into RAM, and if you've included your app in that OS, it will get extracted too.
First, you must include your app files (exe, dlls, all dependencies, etc) into the OS image by adding them to a BIB file.
Next, you must understand that all files get extracted to the \Windows folder. There are no exceptions. If you want it in a different folder, you must use a DAT file to tell the OS where to put it one the OS has been extracted. Be aware that the DAT file does a copy, not a move, so if you want it elsewhere, you'll have two copies of the app on the device. A typical solution is to use the DAT file to place a shortcut, not a full copy.
The last part of your question is the hard, or maybe impossible, part. Your database is not going to persist. You could include a copy in the OS, but every time you hard reset, a new copy of the database as it was when the OS was built will get copied out. No new data will survive.
To get that to work, you need a persistent file store on the device. If you're the OEM, you might be able to implement one with any remaining on-board storage (where the OS image file resides) or with separate mounted USB/CF/SD/HDD media. How you do this is highly hardware and BSP dependent, plus it's way more complex than can be described here on SO.Without knowing anything about the target device, it difficult to even give you any pointer on where to begin. Here's a very generic starting point for Flash storage.

Does releasing a new version of the app delete files of the older one?

I'm gonna release a new version of my app. The previous version used some files which in the newer version are changed and need to be processed. I want the older files to be automatically deleted when the user updates the application, otherwise the application sees them and will process them (resulting in an error because the format of the files changed).
Is there an option to do that?
Thank you.
Since you are processing these files, one option is to somehow put the format version in the files or in folder path. Bake that version into a constant in the app.
The app can either always look for those files by appending the constants to the path where you get these files, or look into the data of the file to get the format version and handle it properly (delete, redownload etc...).
Another benefit is that if you release your app and the format version does not change (likely - you just fixed bugs), you don't have to delete and re-download those files. You also don't have to change anything or update any routines - simply don't change the file format constant and it won't change your files. If you change the format of the files, update that constant and it just works.
It's always a good practice to get the version of your app from the bundle in code and perform necessary changes as needed:
NSString* versionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
Then you can compare this string (or float version of the string) to determine what changes to make to the data. You might delete the old data (as in your case), or extract some of the old data and create new data (the usual way), or the app may need no changes at all.
The BIG thing to keep in mind is you may upload/release several versions of an app and some users may not have downloaded the newer versions. Because of this, it's good practice to have methods update the data based on the version string, instead of expecting it to be the last version of the data.

App store install process

Does anyone know how iOS installs apps after they are purchased
The reason I ask is that I am going to modify a CoreData model and the existing unversioned model .mom file conflicts with the .momd versioned folder in a not clean install process with the usual "'Can't merge models with two different entities named 'Foo'' issue if using mergedModel...
No problem if I discard the app and start again but a big problem for Joe User.
I cant delete the original .mom file programmatically as that hits perms problems
So the question is , is an App Store upgrade a clean operation or is it a delta.
The new version of the application is completely downloaded. Once it is finished, the user files that are identified by the iOS documentation as persistent are copied to the same location in the new copy of the app. The old app is deleted and the application icon on the springboard will now launch the new version.
The answer below is great but also a solution to the actual problem is here
Core data migration failing with "Can't find model for source store" but managedObjectModel for source is present

How to change iPhone App name 100%!

Can't seem change the name of my iPhone app 100%.
I followed multiple threads and performed the outlined methods below, but the old name keeps popping back up in Console. I'm concerned that on some deeper level the app's name has not really been changed 100%.
My concern is with the fact that I've made a "Lite" version by starting with a copy of the "Full" version. So I don't want the device to get confused if my customers upgrade and download the full version and the device see two apps with the same "CORE or ROOT" name.
Console continues to output:
2010-07-03 10:56:35.129 *OldAppName* [45672.207] Test Message
I have changed the Product_name, ".app" name, Bundle name, etc... - Where does "Console" get this name, so I can truly change the app's name 100%? I don't want an conflicts with the full version down the road as the apps grown independently in complexity. (i.e. Push Notifications, iAds, and other "APP" specific items)
I have performed the following, but still not getting 100% name change:
I. I have used Xcode, Project, Rename.
II. I have used the suggested answer on stackoverflow thread, Changing iPhone App's Name, to
Go to Targets in Xcode,
"Get Info" on your project's target (your current silly development name),
Search for "Product Name" under "Packaging". Change the value of that what you want the new program name is going to be.
My "Product_Name" field was blank for all builds, I changed it to the new name, but I continue to get the console output referencing the OldAppName.
III. I'm not trying to change the "Bundle Name", those are the same, as this is a Lite Version. And changing this does not change the Console reference name anyway, I tried.
IV. I have deleted the entire "Build" folder several times to assure no legacy issues, but the name still does not change.
I'm currently working on a large copy/paste migration over to a new project to try and fix this completely with a new project, because I would like to get app uploaded to the AppStore asap, but there must be a better way of achieving this.
Where does the "Console" get this name? Does this mean that if my customers' download the full version that on some deeper level the device will get confused-(i.e. NSUserDefaults with the same names, running issue, sandbox issues, etc...)?
The names are not stored in the info.plist, they appear to just be referenced from the target, but when I search through the target, I don't even find the OldAppName, is their an additional storage file for this core information?
I would like to stay in Xcode if possible. I have seen suggestions about using other programs or trying to change the XML directly through text editor, but I don't want to accidentally leave a "Third-Party" application marker or trial that might get rejected by Apple Reviewer's as they seem to be coming down hard on this issue.
Any detailed suggestions??
I had the same problem about a year ago.
I've got really nice & easy solution for your needs. You need to click on the "superview" of blue icon (Project/Targets) and then hit enter to change the name of the project. You can also double click on that field, but you need to do it with quite a long delay between clicks.
This method will change magically name of the project in all important places.
http://i.stack.imgur.com/3f1RD.png
Only Solution that Worked, and it was the one that feared the most and was trying to avoid.
I had to start a new project and painstakingly move all 96 class files (about 27mb of text) over one by one, because dragging the classes over kept giving me an error. I tried dragging over the classes as one large group, but that would not work. A little "re-factoring", rebuilding the .plist info, and setting up the new targets, and it I got it working again. I think that there was some sort of legacy issues that Xcode was getting caught up on.
It is working now under a new project, but there must be a better way.
Have you tried opening all files in your project in a text editor and searching for the old name?
Have you tried creating a new empty project and merely adding your content and code files to this empty project?
I have done these in the past and found they work fine:
http://drjunker.org/2008/04/10/xcode-rename-project-and-application-change-copyright-and-version-number/
http://homepage.mac.com/kelleherk/iblog/C1216817469/E1454445171/index.html
I also Clean All Targets/Builds and rename the Executable after.
I had a problem when there was a localized strings (infoPlist.strings) file in project with "CFBundleDisplayName"="MyOldAppName" in it. Removing this file and renaming target to my NewAppName worked for me.

Specify build folder for iphone application

I've written an app that uses some of the user's camera roll images, and while it does so it stores them in the application root directory. The problem I have is that whenever I re-compile my application it changes the folder to which the application is installed.
Is there any way I can specify which folder it should build to, so that any path information stored during it's last run will still be valid?
I don't think that this is something you can stop Xcode from doing unfortunately. It should be copying the data from the old location to the new one but sometimes that just doesn't happen.
The answer suggested in this question looks like the solution you are after.