Best option For Syncing Documents Directory Between Devices - ios

I want to keep an apps documents directory that contains sqlite using core data files in sync across users' devices. The sqlite files are the only files in the apps documents directory and simply need to be common to all users' devices
I've tried zipping up the sqlite files to send by email, which works with iTunes file sharing but is not suitable for my needs as it can expose the files to other users' devices.
I've tried using app groups to keep the directory common across devices http://blog.sam-oakley.co.uk/post/92323630293/sharing-core-data-between-app-and-extension-in-ios,
and
Accessing Core Data SQL Database in iOS 8 Extension (Sharing Data Between App and Widget Extension) but that simply did not share the directory across devices for me.
I've sent the file to parse, but pulling them down and reconfiguring the data was the problem there.
I've tried using iCloud and even the Apple engineer gave up on that one.
What I'm after is the simplicity of file sharing through iTunes (being able to replace the sqlite files) with a bit more finesse and without the need to plug in the device.
Some considerations
The whole model can be synced in one go
Data does not need constant syncing facilities, a manual sync option would suffice.

Related

(iCloud) How to programmatically Backup/Restore data for all Apps like iTunes does?

I'd like to backup and restore files (or other type of informations like key-value, SQL-like transaction based info.) for NOT ONLY my app but also all the other Apps using iCloud.
I'm just new to iCloud and read only a few documents but it seems iCloud APIs are just for single App boundary (of course I understand there is an option for sharing information between 'Group' of applications).
What I want to do is backup and restore almost everything. How can I do that?
(There some apps doing this like
http://www.copytrans.net/copytranscontacts.php
http://www.macrumors.com/2012/05/18/elcomsofts-phone-forensics-software-offers-near-real-time-access-to-icloud-backups/)
I checked that the some of the Mobile App files are stored inside the "~/Library/Application\ Support/MobileSync/Backup" directory but there are only some of the files from all the files actually stored in iCloud.
And I tested CloudKit, but it just takes control over App's own data only.
Thanks in advance.
One thing to keep in mind when thinking about this is that iTunes actually doesn't backup or restore anything to/from iCloud. iOS device does it on its own: there's a daemon process running and if iCloud Backup is enabled, it will backup directly to iCloud, without talking to iTunes. Restore is also done without interaction with iTunes.
Next, as #rmaddy pointed out, your app on the device cannot access files of other apps, so you won't be able to do what you want from the device. If you want to do this via companion app running on PC/Mac then it might be possible, but will depend on what exactly do you need/want.
Re: contacts. Apps can access AddressBook and thus can sync/upload its contents. Apps can also access some other shared data, such as Photo Library. This is still a far cry from your original request to "Backup/Restore data for all Apps".
Re: downloading iCloud backups. Downloading isn't a big deal those days (Disclosure: I am the author of that forensic tool to download iCloud backups you're mentioned). There is even an open-source code for that. However, downloading and restoring are two very different processes. Specifically, you can download, but your app won't have enough permissions to write files in place.
Hope this helps and clears things up.

Are app files unique to installations

I'm planning on having a generated file be stored in the App/Documents file for my app. I want this file to be unique across installations so that if a user has an iPad and an iPhone they will have two different versions of the file.
I've been reading the specification(https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html) and am particularly concerned about this line.
Use this directory to store critical user documents and app data files. Critical data is any data that cannot be recreated by your app, such as user-generated content.
The contents of this directory can be made available to the user through file sharing. The contents of this directory are backed up by iTunes.
My question is will the files be backed up to the users account in the cloud?
yes it is. The Documents Directory is a key location in an app. which means that if you put anything in the documents, it will back up to itunes(if the user wants to). so even if you generated a unique file across installations, it will re-download the EXACT file to a new system if they downloaded it previously. so unique files in the DOCUMENTS will not be possible (unless a person uses a diffrent apple account on every one of his devices. which is not likely.)

Marmalade SDK - How to make data persistant after update

How do I keep the users data when they get an update.
I use the Marmalade SDK to develop an app and I saved the user data to bin files and text files, I used the ram:// prefix when saving the files.
If I delete the app and get it from the app store again with the could symbol It had lost all its user data. I would like to release an update that doesn't delete the users data. The app does not come with any user data files, the app creates them as you use it.
Edit: Marmalade is cross platform but my question is for iOS only and the app has been publish, I am asking with respect to an existing app.
Deleting the app from the device, also removes it's sandbox. So any user data stored locally is deleted. This is expected behaviour.
If the user data comes from the web, then you just need to download it again.
Have you read the tutorial for dealing with files?
I have never used that sdk but:
rom for the read-only portion of your apps data area and is read only.
ram for the writable portion of your apps data area. This drive is the only drive that is guaranteed to exist across platforms
rst for a removable memory card on the phone or tablet
raw for paths that will be passed directly to the underlying operating system without modification. (not supported on all platforms)
tmp for a system temp folder, outside of the s3e data area. (system temporary folder and currently only available on iOS)
So maybe you could try rst:// and get the expected result?

Should I follow iOS Data Storage Guidelines?

My iOS app is intended to be compatible with iOS 5.0 and above, and it has iCloud capabilities turned off in it's target settings, I'm not integrating with iCloud. My app stores an sqlite file and some image files into Documents folder. The sqlite file is not downloadable, but images are.
I've read some posts from people saying that their app's submission was rejected because they don't met the iOS Data Storage Guidelines, but I'm not sure if that is only required if your app has iCloud capabilities enabled, is it? Should I set the NSURLIsExcludedFromBackupKey for my files anyway?
Thanks in advance
EDIT
I've read this here:
It is not possible to exclude data from backups on iOS 5.0. If your app must support iOS 5.0, then you will need to store your app data in Caches to avoid that data being backed up. iOS will delete your files from the Caches directory when necessary, so your app will need to degrade gracefully if it's data files are deleted.
But I need the sqlite file to be in Documents to insert data... how should I handle this?
It has nothing at all to do with whether your app uses iCloud or not. It has to do with the user performing backups to iCloud which is beyond the control of your app.
If all of the data in your app that is stored in the app sandbox is data that is created and stored by the user through the use of the app then Apple will have no problem with the data being backed up.
They have issue with replaceable files being backed up needlessly. If the database file is read-only and could be obtained from a server or the app bundle then don't let it be backed up. But if it starts out mostly empty and then gets data added as the user adds data through the app then it should be backed up. Same for the images.

Does iCloud upload all files in the Documents directory to the cloud servers?

I was under the impression that iCloud only worked with UIDocument files.
How about other types?
Also if my user's files get uploaded into the cloud, can he use those files with all his devices if my app is universal?
According to Apple's File System Programming Guide,
Handle support files—files your application downloads or generates and
can recreate as needed—in one of two ways:
In iOS 5.0 and earlier, put support files in the
/Library/Caches directory to prevent them from
being backed up
In iOS 5.0.1 and later, put support files in the
/Library/Application Support directory and apply
the com.apple.MobileBackup extended attribute to them. This
attribute prevents the files from being backed up to iTunes or
iCloud. If you have a large number of support files, you may store
them in a custom subdirectory and apply the extended attribute to
just the directory.
iCloud does back up of the things under Library also.
Ans YES of course if user's files get uploaded into the cloud, then he can use those files with all his devices if the app is universal as iCloud is intended to be the invisible magic that glues your iPhone, iPad and Mac (if you use one) together.

Resources