mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-26 21:51:05 +01:00
feat(xcode): support Package.swift
as project file in xc
(#10358)
This commit is contained in:
parent
2e46b2a2dc
commit
1861b5f175
2 changed files with 10 additions and 20 deletions
|
@ -26,7 +26,7 @@ plugins=(... xcode)
|
||||||
|
|
||||||
### `xc`
|
### `xc`
|
||||||
|
|
||||||
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.
|
Opens the current directory in Xcode as an Xcode project or a Swift package. This will open one of the `.xcworkspace`, `.xcodeproj` and `Package.swift` files that it can find in the current working directory. You can also specify a directory to look in for the Xcode files.
|
||||||
Returns 1 if it didn't find any relevant files.
|
Returns 1 if it didn't find any relevant files.
|
||||||
|
|
||||||
### `xx`
|
### `xx`
|
||||||
|
|
|
@ -6,28 +6,18 @@ alias xcsel='sudo xcode-select --switch'
|
||||||
# original author: @subdigital
|
# original author: @subdigital
|
||||||
# source: https://gist.github.com/subdigital/5420709
|
# source: https://gist.github.com/subdigital/5420709
|
||||||
function xc {
|
function xc {
|
||||||
local xcode_proj
|
local xcode_files
|
||||||
if [[ $# == 0 ]]; then
|
xcode_files=(${1:-.}/{*.{xcworkspace,xcodeproj},Package.swift}(N))
|
||||||
xcode_proj=(*.{xcworkspace,xcodeproj}(N))
|
|
||||||
else
|
|
||||||
xcode_proj=($1/*.{xcworkspace,xcodeproj}(N))
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [[ ${#xcode_files} -eq 0 ]]; then
|
||||||
if [[ ${#xcode_proj} -eq 0 ]]; then
|
echo "No Xcode files found in ${1:-the current directory}." >&2
|
||||||
if [[ $# == 0 ]]; then
|
|
||||||
echo "No xcworkspace/xcodeproj file found in the current directory."
|
|
||||||
else
|
|
||||||
echo "No xcworkspace/xcodeproj file found in $1."
|
|
||||||
fi
|
|
||||||
return 1
|
return 1
|
||||||
else
|
|
||||||
local active_path
|
|
||||||
active_path=$(xcode-select -p)
|
|
||||||
active_path=${active_path%%/Contents/Developer*}
|
|
||||||
echo "Found ${xcode_proj[1]}. Opening with ${active_path}"
|
|
||||||
open -a "$active_path" "${xcode_proj[1]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local active_path
|
||||||
|
active_path=${"$(xcode-select -p)"%%/Contents/Developer*}
|
||||||
|
echo "Found ${xcode_files[1]}. Opening with ${active_path}"
|
||||||
|
open -a "$active_path" "${xcode_files[1]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Opens a file or files in the Xcode IDE. Multiple files are opened in multi-file browser
|
# Opens a file or files in the Xcode IDE. Multiple files are opened in multi-file browser
|
||||||
|
|
Loading…
Reference in a new issue