Debugging an iPhone

While a Mac usually “Just Works”, when it does encounter an error situation, OS X often emits a a very vague message that can make debugging a long-winded process. For example, suppose you have recently brought home a shiny new iPhone and upon connecting it to iTunes you receive: “Could not connect to iPhone because an unknown error occurred (0xE8000001)”.

According to the web, it seems the most common cause of this is connecting the iPhone via a USB hub instead of directly to the computer, but I had no USB hub. Also, most people were experiencing this as a transient fault after regularly and successfully synchronising their iPhone for some months, while mine was a new connection—all very perplexing.

Fortunately, OS X is really UNIX in disguise, and so while the user interface tries to only display friendly messages, the technical details are being logged in the same way as any other UNIX system, hence I checked /var/log/system.log:

Jul 16 12:45:05 yvaine [0x0-0x10010].com.apple.iTunesHelper[136]: MobileDevice: 
AMDevicePair: Could not mkdir /Users/ned21/Library/Lockdown: Permission denied
Jul 16 12:45:05 yvaine [0x0-0x10010].com.apple.iTunesHelper[136]: MobileDevice: 
store_dict_osx: Could not create /Users/ned21/Library/Lockdown/
6b90d8c839e8ec9e74d2dffce9a2e111daf84f7b.plist: No such file or directory
Jul 16 12:45:05 yvaine [0x0-0x10010].com.apple.iTunesHelper[136]: MobileDevice: 
AMDevicePair: Could not store pairing record at 
/Users/ned21/Library/Lockdown/6b90d8c839e8ec9e74d2dffce9a2e111daf84f7b.plist

Aha!—a simple case of “permission denied”. (Which, lets be honest, to a non-techie person would be no less cryptic than the message that the GUI actually displays.) This did present another mystery though since permissions on ~/Library look normal:

yvaine:~ ned21$ ls -ld Library/
drwx------+ 42 ned21  ned21  1428 22 Jun 10:34 Library/

except for that little + sign at the end of the permissions string. A quick check on another mac indicates that this is in fact not normal, and means that the directory has an extended ACL (this is the same convention as in Linux) but unlike Linux, OS X does not have getfacl(1) and setfacl(1) commands for viewing and manipulating ACLs—use “ls -le” instead.

yvaine:~ ned21$ ls -lde Library/
drwx------+ 42 ned21  ned21  1428 22 Jun 10:34 Library/
 0: group:everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown
 1: group:everyone deny delete

I have no idea how these ACLs were added to my directory, but let’s wipe them out:

yvaine:~ ned21$ chmod -a# 1 Library/
yvaine:~ ned21$ chmod -a# 0 Library/
yvaine:~ ned21$ ls -lde Library/
drwx------  42 ned21  ned21  1428 22 Jun 10:34 Library/

And my iPhone worked like a charm.

2 Responses to “Debugging an iPhone”

  1. Too busy to… » Blog Archive » So is the iPhone any good? Says:

    […] « Debugging an iPhone […]

  2. YYota Says:

    Thanks a lot for posting this, I had the exact same problem… you made my day, thank you!