Skip to content
Vineet Choudhary edited this page May 3, 2017 · 1 revision

CoreSimulator is attempting to unload a stale CoreSimulatorService job

launchctl remove com.apple.CoreSimulator.CoreSimulatorService || true

xcodebuild: “No applicable devices found.” when exporting archive

This was a conflict with our use of a non-system ruby via rvm. To fix, you need to call xcodebuild inside the context of rvm use system. But doing this is complicated by the fact that using rvm in scripts is harder than it should be.

We created a script which fixed this for us:

    
# This allows you to use rvm in a script. Otherwise you get a BS
# error along the lines of "cannot use rvm as function". Jeez.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

# Cause rvm to use system ruby. AFAIK, this is effective only for
# the scope of this script.
rvm use system

unset RUBYLIB
unset RUBYOPT
unset BUNDLE_BIN_PATH
unset _ORIGINAL_GEM_PATH
unset BUNDLE_GEMFILE

set -x          # echoes commands
xcodebuild "$@" # calls xcodebuild with all the arguments passed to this

This is a drop-in replacement for xcodebuild, where

xcodebuild arg1 ... argn

would become

path/to/xcbuild-safe.sh arg1 ... argn

I've gisted a production-ready version. Make sure you chmod +x on that file.