IOS Enterprise Distribution update keep user data? - ios

I'm making an iPad app which will be distributed from my own web server using Enterprise Distribution Program.
The app itself checks for a newer version on the server and calls itms-services in IOS to update itself. This works perfect.
The app bundle contains a directory with resources like images and movies.
Apple claims that updates will keep the users data if the bundle-identifier is the same.
From: http://help.apple.com/iosdeployment-apps/mac/1.1/#app43ad802c
If you want users to keep the app’s data stored on their device, make sure the new version uses the same bundle-identifier as the one it’s replacing, and tell users not to delete their old version before installing the new one. The new version will replace the old one and keep data stored on the device, if the bundle-identifiers match.
When running the app from Xcode directly to my connected iPad, I can remove the folder with my resources, run the app again, and the folder remains in the bundle on my iPad.
This behavior is what i look for. I'm planning on adding more folders with new resources with new updates. Since the resources are quite heavy, I don't want users to have to download bigger and bigger archives. I want to add just the new stuff.
The problem arises when I make a new archive without the folder and update the app from my web server as users would. Then the folder seems to be deleted.
Any experience with this?

The bundle that you install is always overwritten by the new bundle that you install. The user data referred to in the documentation is the data stored in the Documents and Library folders of the file system. If you wish to be sure that the old bundle files will always be available, you can copy them from the bundle to the Library/Caches folder of the application.
One thing worth mentioning is that the way to ensure that the ad hoc installation overwrites the current bundle is to make sure that you change the bundle version.
hope this helped :)

Related

Xcode migrate Core Data to new Bundle ID

I want to change my bundle ID (just make it lowercase) because the bundle ID I set up in App Store Connect is all lowercase, but my old bundle ID in Xcode had an uppercase letter. Changing it in Xcode is straightforward, but when I run the app on my device, it installs a duplicate app instead of replacing the old version (because the bundle IDs have different capitalization). I'm using Core Data for my data persistence, and since I've been testing the app on my own device for a while and adding data through that, I would really like to keep the data I have but migrate it to the app with the new bundle ID.
All the related questions I've found so far are concerned with only changing the bundle ID, but not with maintaining the existing data. Is there a good way to do this?
If you change the bundle ID, then it's a different app, as far as iOS is concerned. You have two different apps that happen to have similar bundle IDs, but they can't access each other's data any more than any two random apps can do that.
If you have not released your app, meaning it's still in development, you can copy data out of the old version and then upload it to the new version. You would use almost exactly the steps in this answer except that in your case you wouldn't delete the app until you were sure the copy was working normally. With these steps you basically copy the data from one version to your Mac, then copy it from the Mac to the other one.
If you have already shipped your app, it's more complicated. One way would be to update the app using the old ID but enable app groups. Have the update copy its data into the shared app group folder. Then enable app groups with the new ID and have it use the same shared folder. Another approach would be to have both versions sync data via some online service-- CloudKit, or Firebase, for example-- so that when the app gets the new ID it will get the new data by syncing it in.

Updating iPhone app removed the older version data

I am developing a social application for iOS using Objective-c. But when I published the newer version of my app and upgraded it using App Store, all of my older application data has been removed while every thing in both versions is the same like Bundle Identifier, Provisioning Profile, Signing Certificate. But I am confused why some thing like that happened. I was wondering if anyone could help me. This is too important for me, because this problem forces users to register again in the application.
update: I save data in the documents and also using core data
It might not be cleared just the path of the files changed, for example lets say you save the path of a photo like this :
/data/Containers/Data/Application/B42FE84A-E031-4A2C-AEA7-8D77AEAA389C/Documents/Photo.jpg
when you update the app the path will look like this because iOS will change app documents folder
/data/Containers/Data/Application/757455E1-355B-4040-8ABB-85F39D650A1E/Documents/Photo.jpg
so the file still exist but the path have changed and since you are saving the path the app won't find it because it was changed
i recommend saving only file name not the whole path

Fetching previous saved database file after reinstalling the app

I am new to ios development so please pardon if I am asking a silly question.
I need to check if my sql file from the previous installation of the same app exists in the device directory already. If yes, then I need to fetch that file instead of making the new one. But the bundle folder of the app changes after reinstalling the app. So I cant guess the name of the previously installed app bundle folder. I tried to save it elsewhere on the device, but it isn't allowing me. Please suggest me the solution.
What you're asking for isn't possible. If an app is removed, all its files are deleted as well. In iOS, there is no app-neutral place to store files. When an app is merely updated, the update happens "in place" from the perspective of the app, and all previous files are available.
If you want files to survive a delete-reinstall cycle, you'll have to use a cloud service, such as iCloud, Dropbox or Google Drive.
once app is deleted. Application bundle and document directory and all files (including SQLite file)are deleted. u have to fetch all data from API.
In iOS each application is a Sandbox. This Sandbox consists of Application bundle and Mutable part where you store your database and other files which are mutated during the life span of an application.
When you delete the application, entire Sandbox is removed. The only thing which does not get remove is the data which you have stored in keychain.
When you update the application, only application bundle gets updated and Mutable part remain un-touched. So while re-installing the application when it is already present (technically updating the existing application on the device), you can find the same file from the same location.
You can do one thing you can take daily backup of that file on remote server and when you reinstall app check that file exist on server if exists than download else create new.

Why is a new project with the same app ID still designated a new location?

We have created a new project with the same app ID, but this is designated a different folder in isolated storage. Why is this?
file:///Users/houman/Library/Developer/CoreSimulator/Devices/FBFFFF1E-B5C8-4541-AB4B-ED1657D43EB9/data/Containers/Data/Application/EB3A549F-1604-4E5C-8FBE-3076A3D581E5/Documents/
file:///Users/houman/Library/Developer/CoreSimulator/Devices/FBFFFF1E-B5C8-4541-AB4B-ED1657D43EB9/data/Containers/Data/Application/22E1E792-1F4F-4F05-B7D9-F61AD3624EE9/Documents/
Even though the apps share the same ID.
Since they don’t share the same location, no core data migration can take place.
Any advice please?
Update:
We have two apps in the AppStore and would like to combine the functionality. Hence the idea is to use the appID of the other app to push a new release from a separate project. We have the appID and right certificates, but the isolated storage seems to depend on something else than just appid. Without that a migration of existing data to the new system won't be possible. Alternatively we could copy and paste all files into the other project and go through lots of pain. That might make it possible.
I have seen this on my end - I believe (and could be wrong) that each simulator you run in gets its own folder on the disk. If you switch for iPhone 5 to iPhone 6s for example you may end up with a different folder.
I always actually (when running in the simulator) print out the on-disk location so that I can take a look at the sqlite file if i need to and recently (as of xcode7) i've noticed this directory change between runs - however in my case i tracked it down to changing simulator versions.
Mainly for security reasons. Every iOS application is placed in an application sandbox.
This not only refer to an application's sandbox directory in the file system, granting security by limiting the access to user data stored on the device, system services, and hardware.

Apple AppStore update process: how it affects the existing files

from what I understand an Apple app update would be installing a new standalone application instead of applying a patch to the existing one.
Does anyone know more details about this process? This applies to all the directories for the user? Any folders like Private Documents will be left untouched by the update. How about the other folders like Documents, etc.. I am hoping to find a document describing the behaviour, but could not find one so far on the web.
By update I mean: let's say the user has version 1.2 ... and then pulls data from the application server when available. And then 1.3 comes online to the App Store.. the user updates to 1.3.
As explained here: iOS App Programming Guide, all you need to know about updates is that:
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.

Resources