iCloud Documents syncing, but can't be opened on other devices - ios

I have a document based iCloud app that is giving me grief. Things used to work on iOS 7, but now they don't. I think it dates back to iOS 8.0 upgrade. Here's the problem:
In my app I create a UIDocument in iCloudURL/subDir and everything works fine on that device (call it DeviceA). I can close the app, start it again and read the file. Great! So I break out my second test device (DeviceB) and my directory query finds the all files I created on DeviceA. However, when I try to open them I get 'NSCocoaErrorDomain Code=260' which basically means "no such file or directory". Similarly, if I create files on DeviceB I can't open them DeviceA.
Another point of interest is that if I check "Setting->iCloud->Storage-Manage Storage -> AppName", the files are listed on BOTH devices regardless of where they were created.
So obviously I have some kind of iCloud sync problem, but I don't understand what's going on at all. Since iCloud seems to know the files exist, why aren't they syncing properly? Any ideas would be appreciated!
I can add code if that would help, but right now I'm not even sure what to show since most of it works as long as I stay on one device.
Cheers

I was calling
[UIDocument openWithCompletionHandler:^(BOOL success)]
multiple times on the same document before any one of them completed.

Related

transfer my own app from device to xcode

I have built an ios app which I have tested successfully on my ios device. Since last build Ive had to rebuild my laptop and as such Ive lost my xcode project. Is there a way I can transfer the app from my device back into xcode?
The way you are getting your thing is totally different. However you can recover some part of your project data like images, what framework you have used etc.
First you need to connect your device with your system, then open iTunes and select your app then download that app. Now you have to click on that app see option for Show In Finder and click it
If you see your .ipa file, then make it a zip of it and then unzipped it, a payload name folder will appear on your screen. you will see appName.app, right click on it and select show package contents. This will show the app package contents. You can recover few data from that. But if you are thinking to recover code level data then it is not possible.
And you need to make a backup of your project whenever you make any updations so that any accident happened does not affect your main project.
No that´s not possible to do... Next time use Source Control such as Git for example to keep track of your code and prevent this happening in the future (that´s one of many benefits of source control).

How to access Xcode database from iPhone app

This is my first iPhone app. I'm using Xcode 7.3.
In the app I used this tutorial to create an sql database using the app (when the user gives permission by pressing a button, it creates the .db file).
Now I would like to know how I can download the database from the app.
Here is why:
The app will be downloaded on someone's device (not via the app store). It is supposed to collect data from a wearable device and store it in the database.
However I don't know how to access that data later on when I have the user's phone. Apparently the db lives in
/var/mobile/Containers/Data/Application/###/Documents
I read that one method is "jailbreaking." But I have never done that and this is not my phone I'm dealing with, it's a client's, so I don't feel comfortable hacking it. Is there another way? Possibly through the terminal (this is how I did it with the android app, using adb)?
Or is there another way I can go about saving the database so that it is accessible/retrievable?
The first answer is correct but incomplete :
Once you have download the Container, the extension is .xcappdata, so you need to right-click on it and select show the package.
Then browse into /library/Application support/ to find your database in .sqlite
You can try to connect the device to your Mac, then in XCode, go to Window, Devices, select your device and app bundle and click "Download Container...".
To see the database, you could use SQLite.

iOS File Retrieval - NSDocumentDirectory

I am working on a library with a very verbose logger module that, on iOS, writes xml logs to NSDocumentDirectory in a consistent file tree. I want to come up with a way for the user of this library to easily access these logs.
I know it is simple to programatically retrieve files from this directory, but is it possible to access this directory on an iOS physical device in any way from outside Xcode to retrieve these logs? I feel like I have seen it somewhere before, something in the manner of extracting the .ipa file and going into the package contents, but I could be wrong.
---------------------------------------------------------EDIT------------------------------------------------------------------
This (Browse the files created on a device by the IOS application I'm developing, on workstation?) is how to do it with Xcode on a device, but I have to assume that there is some way we can create that gets the logs off of a device for a user.
is it possible to access this directory on an iOS physical device in any way from outside Xcode to retrieve these logs?
It is possible to expose the Documents directory by enabling iTunes file sharing. When file sharing is enabled through this method, the contents of Documents directory would be visible to the user in iTunes, which can also be exported. The documents would also be visible for export through some third party desktop apps like iExplorer.
Here is the link to Apple documentation. You may also refer this thread to understand how this is done.
If you're using a simulator (apparently your task doesn't seem to need te real device) you are in luck.
You should go to a folder similar to this one:
/Users/[YOUR_USER_NAME]/Library/Developer/CoreSimulator/Devices/[RANDOM_HASH_YOU_SHOULD_DISCOVER]/data/Containers/Data/Application/[RANDOM_HASH_2_YOU_SHOULD_ALSO_DISCOVER]
Once there, with finder, you'll get the "documents" folder of the simulator and the app you're trying to retrieve your logs from.
You might say: I don't know which 2 RANDOM_HASHES should I go to.
Yes, you're right. If you have MANY simulators installed and or being used, it might be tricky to discover which one is the one you're trying to debug.
The same thing with your APP, your app will live in another RANDOM_HASH folder, and you should browse them, one by one, and then discover your documents folder.
Someone needed to solve this "mess" and created a Xcode Alcatraz Extension that leads you to the exact live simulator and APP you're debugging in any given moment, and then you don't need to guess which 2 random_hash paths you need to navigate to.
If Xcode + Alcartaz plugin extension manager is somewhat out of your reach, you might need to google it. It's not a difficult process.
PS: That magical Alcatraz Extension is named "XCodeWay" (in case you are brave enough to install Alcatraz onto your copy of XCode).
EDIT: Useful link to get Alcatraz: http://alcatraz.io/ Follow its easy instructions and you're done.
EDIT2: If Xcode cannot be used, then the last question in this other thread might come in handy: Browse the files created on a device by the IOS application I'm developing, on workstation?
(Still, an external application in your users machine will be needed )

iCloud query lists deleted files

In my app creates a file on iCloud (outside of the Documents container). This works fine.
I wanted to test the presence/absence of that file. So I built up a NSMetadataQuery that actually detects the file when it is in the cloud. No problem.
Now, I deleted all my apps data from the cloud (using the System preferences), as well as all instances of my app.
Built from scratch and launched the app again. The query is still detecting the file, though it obviously doesn't exist any more, any where...
Any idea how I can get a "correct" file list?
If you want to know what the iCloud service thinks is correct, visit https://developer.icloud.com/ and browse around. That will show the server-side view of the iCloud account.

Inspect iOS user's documents folder remotely

Recently a user of one of my apps reported that all her data was lost when she updated the app. I think this is a long shot, but is there anyway for me to inspect her 'documents' folder within the app on her iPad? Or a way for her to send me her document folder so I can see what's going on and hopefully salvage the data?
If she is a fairly technically capable user, you could have her use PhoneDisk http://www.macroplant.com/phonedisk/ to mount your app's sandbox and inspect the Documents folder.
If it is a jailbroken device you could ask her to download teamviewer, then ssh into the iPad.
Never tried it though! But that was an idea I got when I saw your question.
http://www.idownloadblog.com/2011/03/14/how-to-ssh-into-your-iphone/

Resources