Skip to content

Instantly share code, notes, and snippets.

@ricardopereira
Created June 14, 2018 22:41
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricardopereira/adae5038191ac9f8d4ee03c23fde1b8c to your computer and use it in GitHub Desktop.
Save ricardopereira/adae5038191ac9f8d4ee03c23fde1b8c to your computer and use it in GitHub Desktop.
How to enable/disable “Show as run destination” for all simulators https://stackoverflow.com/questions/50796954/how-to-enable-disable-show-as-run-destination-for-all-simulators
simulatorsIdentifiers=$(instruments -s devices |
grep -o "iPhone .* (.*) \[.*\]" | #only iPhone
grep -o "\[.*\]" | #only UUID
sed "s/^\[\(.*\)\]$/\1/" | #remove square brackets
sed 's/^/"/;$!s/$/"/;$s/$/"/' | #add quotes
sed '$!s/$/,/' #add comma to separate each element
)
arrayOfSimulatorsIdentifiers=($(echo "$simulatorsIdentifiers" | tr ',' '\n'))
# Add simulators to DVTIgnoredDevices
echo "${#arrayOfSimulatorsIdentifiers[@]}"
for index in "${!arrayOfSimulatorsIdentifiers[@]}"
do
echo "$index Adding: ${arrayOfSimulatorsIdentifiers[index]}"
done
defaults write com.apple.dt.Xcode DVTIgnoredDevices -array ${arrayOfSimulatorsIdentifiers[@]}
@ricardopereira
Copy link
Author

If you want to hide all iPad and iPhone simulators then change line 2 with grep -e "iPhone .* (.*) \[.*\]" -e "iPad .* (.*) \[.*\]" | #iPhone and iPad

screen shot 2018-06-15 at 00 50 49

@palaniraja
Copy link

This is a god send. Thanks you.

All I want is to reorder devices displayed in run target. What can I say a $trillion company can't assign a resource for it.

My current solution is disable everything and enable only the few I use.

@abdulajet
Copy link

for xcode 13 this works for me

simulatorsIdentifiers=$(xcrun xctrace list devices |
  grep -e "iPhone" -e "iPad" |  #iPhone and iPad
  grep -oE "[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}" | #only UUID
  sed 's/^/"/;$!s/$/"/;$s/$/"/' | #add quotes
  sed '$!s/$/,/' #add comma to separate each element
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment