5

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.

Community
  • 1
  • 1
dokun1
  • 2,120
  • 19
  • 37
  • Wouldn't `UIFileSharingEnabled` work for you? A non-technical user would be able to extract log files from the documents directory using iTunes or a third party app like iExplorer. – Vin Mar 14 '16 at 08:27
  • Hadn't thought of that. My initial research seems to show me that will work, so can you post as an answer while I try it out, so I can give you credit if it does? – dokun1 Mar 14 '16 at 09:13

2 Answers2

2

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.

Community
  • 1
  • 1
Vin
  • 10,517
  • 10
  • 58
  • 71
  • 1
    FYI - we generate our library using Cmake from cross-platform code, so this means we may have to make a sample project with these two keys activated in the plist from scratch. We'll script it out, but thank you so much!!! – dokun1 Mar 14 '16 at 09:54
1

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 )

Community
  • 1
  • 1
Isaac
  • 1,794
  • 4
  • 21
  • 41
  • I'll update the question, your answer is correct for the simulator, but I need it for iOS devices. – dokun1 Mar 11 '16 at 11:40
  • Ok then... Inside Xcode go to Window ->Devices. Once there, select your real device, and I can remember some kind of "right button click" option somewhere that let you browse (crappily) the contents of your device sandbox. But I can't remember if you can download these files – Isaac Mar 11 '16 at 11:41
  • Xcode is out of the question. I need for a non-developer user to be able to access these logs. – dokun1 Mar 11 '16 at 11:42
  • Out of ideas then :) – Isaac Mar 11 '16 at 11:43