5

I need to access the sandbox directory for an application installed on an iOS device, using the command line (non-gui) from a Mac or Linux. This is to help with development and testing automation. Dropping a json file into the sandbox lets me set parameters like extra debug messages and smaller refresh intervals.

A tool like iFunBox works perfectly but is graphical only, requiring numerous clicks to do this. Emails to the developers were unanswered. It also does not support AppleScript. I did find another app that provided a Fuse module, but it turned out buggy especially if the app was uninstalled and then reinstalled (in order to reset back to first time user experience). I reported the problems to the developer but there is no fix on the horizon.

The things I need to do are:

  • Test if an app with a specific bundle id is installed
  • Create Library/Caches/MYLIBNAME directory if it doesn't exist
  • Copy a ~100 byte json file from the Mac to that directory
  • Get a copy of that file
  • A solution that only works from Linux is acceptable too
  • Devices are not jailbroken and I would prefer not to need that as a requirement

In some cases I do not have the source code to the app since it is a third party using my library, so compiling different versions of the app isn't practical.

Answer is below in many comments thanks to lxt. Summary is:

  • Various libraries and programs associated with libimobiledevice can solve the problems
    • Use patched iFuse to mount an application sandbox
    • Use idevicesyslog to see the console log
    • Use ideviceinstaller to install/uninstall apps
  • The various libraries and programs associated with libimobiledevice are incredibly difficult if not impossible to compile as is on Linux or Mac, and there is no unified distribution of the source or binaries
    • For Ubuntu try libimobiledevice (may have 3 suffix), ideviceinstaller and libimobiledevice-utils packages
    • For Mac a search for libimobiledevice-macosx may get you some of the way there
Roger Binns
  • 3,203
  • 1
  • 24
  • 33

3 Answers3

1

This is going to be a little tricky, because as I think you've found out the application name is randomly generated on every install. I don't think there is a way past that, certainly that I know of. This explains the problems you're running into when simulating a new install (...the app directory name changes to a new, random hash, and then you're stuck).

Although my preference would be to access this config file in some other way (perhaps over a network, and have some code that only executes on debug/test builds check for it), if you did want to do this then I'd suggest trying something like writing a script that when you want to simulate a new install chooses the app directory that's most recently modified. But this is very hacky.

If you're not able to insert conditional code that only executes on debug/ test builds then I think the random app naming schema that iOS uses at a file system level is going to be problematic for you whatever approach you take.

Update: Regarding iFuse and libimobiledevice - out of the box it limits you to the documents directory. This is because the authors of iFuse don't entry-level users to be confused, and also because the structure is a little different depending on iOS version. You can comment out the lines in the iFuse source - fuse_opt_add_arg(&args, "-osubdir=Documents"); - to get access to the library directory through the mount. You will obviously need to re-compile iFuse yourself if doing this.

lxt
  • 31,146
  • 5
  • 78
  • 83
  • I'd be happy to do all that, but I don't have a way of doing command line access in the first place. Once I have that everything else is easy/SMOP. All the tools I can find are GUI and non-automatable in any way, which is the problem. – Roger Binns May 09 '13 at 17:34
  • Ah, sorry about that - this is what you're after: http://www.libimobiledevice.org/ - it works on non-jailbroken devices, although obviously you only have access to the apps directory. Should be fine on Linux, although I've only used it on OS X. – lxt May 09 '13 at 19:39
  • Are you sure that libimobiledevice can access the application sandbox directories (Library, Caches etc)? I did look at it for quite a while and couldn't find any evidence that it could. It could definitely access the other directories (App file sharing etc) but that isn't useful to me. As far as I can tell they use different protocols. – Roger Binns May 09 '13 at 21:41
  • Assuming you're using libimobiledevice through iFuse: the protocol is the same, it's just that the stock iFuse install limits it so as not to confuse entry-level users. I am going to update my answer rather than post it in a comment, as you'll need to modify the source – lxt May 10 '13 at 08:16
  • It was a nightmare getting the dependencies compiled/working. In the end I had to pick up precompiled parts from random PPAs. But iFuse did work. I haven't tested how it behaves when the app is uninstalled and reinstalled, but assume it will break. However being command line means I can address that. The only remaining missing piece on Linux is getting the console log. (There is no precompiled ifuse+dependencies for Mac, macports doesn't know about it, and there is no way I'm trying from source.) – Roger Binns May 11 '13 at 07:57
  • You can get the console log on Linux with libimobiledevice as well - see this question: http://stackoverflow.com/questions/7277804/ios-iphone-ipad-ipodtouch-view-real-time-console-log-terminal – lxt May 11 '13 at 08:57
  • idevicesyslog is available as an Ubuntu package so that solves that problem. – Roger Binns May 12 '13 at 01:20
  • Thanks for all your help - I now have everything working on Linux and Mac looks like it would be even harder. I've summarised the answers at the bottom of the question. – Roger Binns May 12 '13 at 01:35
0

You can make use of MobileDevice Library

Ocelot
  • 1,733
  • 4
  • 29
  • 53
  • Ocelot, can you please let me know how can we make use of this? I like to transfer some of Documents (on device) file to mac machine through command line – iamMobile Jun 06 '14 at 22:53
0

I know this is an old question and I doubt anyone is looking here anymore, but I thought I'd mention that you can use 'brew install libimobiledevice' to compile on the mac. There are a lot of dependencies and Homebrew really helps make it an easy process by installing them for you.

Teresa Peters
  • 229
  • 3
  • 14