mountainstorm / MobileDevice

A python package, and command line tool, which wraps Apple's MobileDevice API - providing access to iOS devices.
MIT License
195 stars 67 forks source link

RuntimeError: Unable to start service com.apple.afc #14

Closed mattieb closed 3 years ago

mattieb commented 10 years ago

Once I've resolved issue #13, I cannot afc ls /var/mobile/Media:

$ python MobileDevice afc ls /var/mobile/Media
0: (UDID) - "(device name)"
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/matt/src/MobileDevice/__main__.py", line 28, in <module>
    argparse_parse(globals())
  File "MobileDevice/amdevice.py", line 695, in argparse_parse
    cmdargs.parse_args()
  File "MobileDevice/amdevice.py", line 664, in parse_args
    args.func(args, v)
  File "MobileDevice/afcmediadirectory.py", line 148, in cmd_ls
    afc = get_afc(args, dev)
  File "MobileDevice/afcmediadirectory.py", line 132, in get_afc
    retval = afcmediadirectory.AFCMediaDirectory(dev)
  File "MobileDevice/afcmediadirectory.py", line 31, in __init__
    s = amdevice.start_service(AMSVC_AFC)
  File "MobileDevice/amdevice.py", line 330, in start_service
    raise RuntimeError(u'Unable to start service %s' % service_name)
RuntimeError: Unable to start service com.apple.afc
mountainstorm commented 10 years ago

Strange; have you tried checking you have a pairing record; either by using XCode/iTunes to talk to the device or running "mdf dev pair" - you'll need to click the "Trust" dialog on the phone first

mattieb commented 10 years ago

Pairing seems to be fine. I use iTunes regularly with the device (iPhone 4S, iOS 7.0.4), but I ran dev pair anyway.

Weird bit, though, after I pulled your latest version I was able to do afc ls /var/mobile/Media once, then as I started exploring other commands I started getting the above Unable to start service error. After that, nothing seemed to work, until I rebooted the device. As I write this, it's working perfectly with everything.

I'm very puzzled…

mountainstorm commented 10 years ago

You are not alone; very strange. It's not something I've seen before and I use these all the time. Are you running the latest version of Xcode? I seem to remember some issues when I had the Xcode 5 beta installed - where I'd occasionally get unexplained failures; but if you kept trying it would start working again.

mattieb commented 10 years ago

Yup, Xcode 5.0.2. Well, I won't be offended if you close this :) but if you have any ideas as to how I might get additional diagnostics out of the failed service starts I'd be happy to try it.