1861b5f175dc8f6d6408772b707c9d6deb28a53f
- Author
- YR Chen <stevapple@icloud.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md
2index 37f882638f6d31430134c316746f135409ab28fa..664a063a32218bbc247c58814130a38f53edebb7 100644
3--- a/plugins/xcode/README.md
4+++ b/plugins/xcode/README.md
5@@ -26,7 +26,7 @@ plugins=(... xcode)
6
7 ### `xc`
8
9-Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory. You can also specify a directory to look in for the Xcode files.
10diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh
11index 89703fe3cf0499ab9c657b32d5b403e9c6a640af..41b9e37e488c3c9eb7beaf8119b0ee92ddc8ff7e 100644
12--- a/plugins/xcode/xcode.plugin.zsh
13+++ b/plugins/xcode/xcode.plugin.zsh
14@@ -6,28 +6,18 @@ alias xcsel='sudo xcode-select --switch'
15 # original author: @subdigital
16 # source: https://gist.github.com/subdigital/5420709
17 function xc {
18- local xcode_proj
19- if [[ $# == 0 ]]; then
20- xcode_proj=(*.{xcworkspace,xcodeproj}(N))
21- else
22- xcode_proj=($1/*.{xcworkspace,xcodeproj}(N))
23- fi
24-
25+ local xcode_files
26+ xcode_files=(${1:-.}/{*.{xcworkspace,xcodeproj},Package.swift}(N))
27
28- if [[ ${#xcode_proj} -eq 0 ]]; then
29- if [[ $# == 0 ]]; then
30- echo "No xcworkspace/xcodeproj file found in the current directory."
31- else
32- echo "No xcworkspace/xcodeproj file found in $1."
33- fi
34+ if [[ ${#xcode_files} -eq 0 ]]; then
35+ echo "No Xcode files found in ${1:-the current directory}." >&2
36 return 1
37- else
38- local active_path
39- active_path=$(xcode-select -p)
40- active_path=${active_path%%/Contents/Developer*}
41- echo "Found ${xcode_proj[1]}. Opening with ${active_path}"
42- open -a "$active_path" "${xcode_proj[1]}"
43 fi
44+
45+ local active_path
46+ active_path=${"$(xcode-select -p)"%%/Contents/Developer*}
47+ echo "Found ${xcode_files[1]}. Opening with ${active_path}"
48+ open -a "$active_path" "${xcode_files[1]}"
49 }
50
51 # Opens a file or files in the Xcode IDE. Multiple files are opened in multi-file browser