So I was recently working with UI Automation using Appium and Cordova, and things were going well. Then suddenly when I launched the iOS Simulator, it would hang, with Appium indicating that it was waiting for the device to boot.
This was, of course, no good, but I couldn’t think of anything that had actually changed — Appium hadn’t been upgraded, and Xcode could successfully launch the simulator.
So I tried a few variations of the command Appium was running, and found I couldn’t launch the simulator either. Of course, nothing was being logged to the terminal, so I launched the Console app.
It turns out that Instruments was complaining that the user didn’t have permissions to do something, which caused Instruments to hang. But, wait! That user was me — I certainly had permission to do so!
And then I remembered — I’d been experimenting with various terminal multiplexers, and I’d gone back to tmux. And sometimes it just so happens that when tmux runs an OS X app, sometimes your own permissions as a user aren’t carried over. This happens when code signing your apps as well.
Thankfully the fix is easy: use
reattach-to-user-namespace. You’ll need to install it if you haven’t already (I’m using homebrew in this example):
$ brew install reattach-to-user-namespace
And then you can either run it manually when you intend on doing something that’s going to fail otherwise:
$ reattach-to-user-namespace your-command and its arguments
Or, you can add it to your config file (
set-option -g default-command "reattach-to-user-namespace -l bash"
If you use a shell other than
bash, be sure to change the value above. I use
fish, so I changed
Of course I was searching Google for a solution to my woes during all this and banging my head against my desk frantically. The above is a result of coming across this webpage written by Brendon Rapp from Economy of Effort. So credit goes to Brendon for clueing me in to the problem.