Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command line access to iOS app directory (sandbox) from Mac

Tags:

ios

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
like image 976
Roger Binns Avatar asked Nov 12 '22 07:11

Roger Binns


1 Answers

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.

like image 124
lxt Avatar answered Nov 15 '22 07:11

lxt