-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Match
xcodeproj
file if no xcworkspace
file is found
- Loading branch information
Showing
1 changed file
with
19 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
#!/bin/bash | ||
EXT='xcworkspace' | ||
|
||
DIR=${1:-.} # DIR is either the first argument or the current directory | ||
# DIR is either the first argument or the current directory | ||
DIR=${1:-.} | ||
|
||
shopt -s nullglob | ||
|
||
found=0 | ||
|
||
# Try to open the first xcworkspace file found | ||
EXT='xcworkspace' | ||
for i in ${DIR}/*.${EXT}; do | ||
open -a Xcode "$i" | ||
found=1 | ||
break | ||
done | ||
[ $found -eq 0 ] && echo "No Xcode workspace found" | ||
|
||
shopt -u nullglob | ||
# If nothing was found, try to open the first xcodeproj file found | ||
if [ $found -eq 0 ] | ||
then | ||
EXT='xcodeproj' | ||
for i in ${DIR}/*.${EXT}; do | ||
open -a Xcode "$i" | ||
found=1 | ||
break | ||
done | ||
fi | ||
|
||
# Print message if nothing was found | ||
[ $found -eq 0 ] && echo "No xcworkspace/xcodeproj file found in the specified directory." | ||
|
||
shopt -u nullglob |