Is it possible to view the contents of files in the iOS Application sandbox while debugging?

IosXcodeDebuggingLoggingXcode4

Ios Problem Overview


I'd like to check the contents of an XML file at a specific point of execution while debugging in Xcode. Is it possible to view the contents of the file, either through the Organizer (I'm debugging using actual hardware devices, not the simulator), or by typing in some sort of command into the output/console?

I am using Xcode 4.

Ios Solutions


Solution 1 - Ios

Simply open the organiser and click the 'Download' button at the bottom, then right click on the xcappdata file and select Show Package Contents.

Solution 2 - Ios

Updated answer for Xcode 6:

The Devices tab now has it's own window (Window -> Devices). Find your Device, then your App. There is no 'download' button (unless the log window is visible... then the Download icon there actually saves the Log).

If you DOUBLE-CLICK on your app, a new window will become visible that shows a read-only, non-interactive representation of that app's sandbox.

To download the app container, select an app, click the "Gear" and "Download Container." It'll take a bit of a while, during which time there is no indication of the progress; but a Finder window will appear, showing with your .xcappdata file. You can also "Replace Container" which looks cool and exciting.

Solution 3 - Ios

You could enable file sharing (set the UIFileSharingEnabled flag in info.plist) and store the file where it can be accessed via iTunes (i.e. in the Documents folder).

Solution 4 - Ios

I have just discovered that you can in fact save the entire contents of the sandbox to disk at any time. Simply open the organiser and click the 'Download' button at the bottom. This saves the sandbox to disk as a .xcappdata file. I'm not sure how to open this as it is, but I have found that if you change the file extension to .xml, you can browse it using finder just like a normal directory.

It's a shame you can't download single files if required and that the whole process is a little cumbersome, but it does allow me to achieve what I wanted in the end.

Solution 5 - Ios

You can always set a breakpoint and then, in the console, print the contents of the object you want to examine using 'po'. Example: gdb> po [NSDictionary dictionaryWithContentsOfFile: filePath];.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionWill PragnellView Question on Stackoverflow
Solution 1 - IospstoppaniView Answer on Stackoverflow
Solution 2 - IosJames PerihView Answer on Stackoverflow
Solution 3 - IosSVDView Answer on Stackoverflow
Solution 4 - IosWill PragnellView Answer on Stackoverflow
Solution 5 - IosLioView Answer on Stackoverflow