Closed artemnovichkov closed 5 years ago
Yes, you can. Is there any problem with that?
Just create an sh
script with the following logic (I haven't tested it):
#!/bin/sh
find . -maxdepth 1 -name '*.xcodeproj' | head -n 1 | open -a XCode
Set executable rights (chmod +x) for it and create a corresponding custom action call.
I have a function in .zshrc:
# Xcode via @orta
openx(){
if test -n "$(find . -maxdepth 1 -name '*.xcworkspace' -print -quit)"
then
echo "Opening workspace"
open *.xcworkspace
return
else
if test -n "$(find . -maxdepth 1 -name '*.xcodeproj' -print -quit)"
then
echo "Opening project"
open *.xcodeproj
return
else
echo "Nothing found"
fi
fi
}
And have tried your script, saved to a file and added a path to custom action. The error for both cases:
Unknown error
is my mistake which already got fixed but is not released yet. It happens when the file doesn't have executable rights.
I made the following script called openxcode
:
#!/bin/sh
if test -n "$(find . -maxdepth 1 -name '*.xcworkspace' -print -quit)"
then
echo "Opening workspace"
open *.xcworkspace
else
if test -n "$(find . -maxdepth 1 -name '*.xcodeproj' -print -quit)"
then
echo "Opening project"
open *.xcodeproj
else
echo "Nothing found"
fi
fi
then did: chmod +x openxcode
Then created custom action:
It works.
P.S. The next Fork update will show something like Launch path is not executable '/Users/dan/Sources/openxcode'
instead of Unknown error
in a case of error.
Great! It works, thanks! BTW, I found another issue:
Hi @artemnovichkov, I have the same problem. I think you need to open a new issue and this one close
@jt3k did it https://github.com/ForkIssues/Tracker/issues/370
Can I implement a custom action for opening Xcode projects/workspaces?