ec3694c788d2b32eb1735687cf89b057d4ca4d4d

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Make simulator dependant of currently active dev directory

This also gets rid of `xcode-select` command-not-found errors.

Diff

 1diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh
 2index 059c78fd5345ba0fbb397877786efc3456e14f15..f80de36d5b6f5cd579edcd9be31d9e6f9f6aa2b1 100644
 3--- a/plugins/xcode/xcode.plugin.zsh
 4+++ b/plugins/xcode/xcode.plugin.zsh
 5@@ -17,8 +17,15 @@ alias xcb='xcodebuild'
 6 alias xcp='xcode-select --print-path'
 7 alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*'
 8 
 9-if [[ -d $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app ]]; then
10-  alias simulator='open $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app'
11-else
12-  alias simulator='open $(xcode-select -p)/Applications/iOS\ Simulator.app'
13-fi
14+function simulator {
15+  local devfolder
16+  devfolder="$(xcode-select -p)"
17+
18+  # Xcode ≤ 5.x
19+  if [[ -d "${devfolder}/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app" ]]; then
20+    open "${devfolder}/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app"
21+  # Xcode ≥ 6.x
22+  else
23+    open "${devfolder}/Applications/iOS Simulator.app"
24+  fi
25+}