Fixing “Trust this computer” Problem

I had a strange problem crop up on my iMac running Yosemite and both of my iDevices (iPhone 6, iPad 4). When I plugged either in, I would get a dialog on the iMac saying photos could not be imported because the device was locked. On the devices themselves, I would be asked to Trust this computer. This happened every. single. time.

In the system.log, there were error messages to the tune of:

11/7/14 7:16:52.086 AM usbmuxd[57]: AMDeviceConnect (thread 0x1002fe000): Could not connect to lockdown port (62078) on device 1076 - [long ID number here]: 0xe8000084.

Digging further, I discovered that there is a directory, /var/db/lockdown, that contains a plist for each device connected to the Mac over the years (and since I have been leading an iOS Dev Team for Ozmott, I had a lot of devices listed in there!) and it seems that, for some reason, changes were no longer taking. I am not sure why. There were no errors related to permissions or otherwise.

On the advice of a thread I found online after some extensive Googling, I removed the lockdown directory. Theoretically, it would be recreated by the system. However, it wasn’t. Now when I connected my devices, I got the following errors:

11/7/14 7:22:44.510 AM com.apple.usbmuxd[57]: WriteDataToPath unable to create file /var/db/lockdown//SystemConfiguration.plist.tmp: No such file or directory.
11/7/14 7:22:44.510 AM com.apple.usbmuxd[57]: CreateAndStoreBUID WriteDataToPath failed: No such file or directory

So, I created a new lockdown directory using sudo mkdir lockdown. Then the errors changed to:

11/7/14 7:27:09.767 AM com.apple.usbmuxd[57]: WriteDataToPath unable to create file /var/db/lockdown//SystemConfiguration.plist.tmp: Permission denied.
11/7/14 7:27:09.767 AM com.apple.usbmuxd[57]: CreateAndStoreBUID WriteDataToPath failed: Permission denied

The directory was owned by root (because I created it using sudo) and clearly needed to belong to the usbmuxd process. Directories belonging to processes are named for the process preceded by an underscore. So I executed: sudo chown _usbmuxd lockdown.

That worked. Plugging in my devices resulted in the same dialogs as before but once I told the iDevices to trust the computer, new plist files were created for each and subsequent connects/disconnects have not had the errors recur. We’ll see if this sticks over time but at least I know how to fix it, even if temporarily.

Update 18 December 2014: The problem routinely returns. After I leave my computer running for a day or so, the problem comes back. I haven’t needed to resort to the fix above as simply rebooting my computer fixes it. It’s safe to say that something I am running on my machine is responsible. Now for the sleuthing…

Update 15 January 2015: Solved! Thanks to this thread on Stack Overflow, I have a solution that works! When this happens, open up a terminal and type

sudo launchctl stop com.apple.usbmuxd

And it restarts the broken usbmuxd process and things are happy again.