Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom action for Xcode projects #316

Closed
artemnovichkov opened this issue Jun 21, 2018 · 7 comments
Closed

Custom action for Xcode projects #316

artemnovichkov opened this issue Jun 21, 2018 · 7 comments

Comments

@artemnovichkov
Copy link

Can I implement a custom action for opening Xcode projects/workspaces?

@DanPristupov
Copy link
Contributor

DanPristupov commented Jun 21, 2018

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.

@artemnovichkov
Copy link
Author

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:
screen shot 2018-06-21 at 13 39 02

@DanPristupov
Copy link
Contributor

Unknown error is my mistake which already got fixed but is not released yet. It happens when the file doesn't have executable rights.

@DanPristupov
Copy link
Contributor

DanPristupov commented Jun 21, 2018

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:
2018-06-21 at 09 52

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.

@artemnovichkov
Copy link
Author

Great! It works, thanks! BTW, I found another issue:

  1. Add a custom action
  2. Open Settings > Custom Actions, change the script path, close Settings
  3. Open Settings > Custom Actions again
    New path is not saved.

@jt3k
Copy link

jt3k commented Jul 30, 2018

Hi @artemnovichkov, I have the same problem.
I think you need to open a new issue and this one close

@artemnovichkov
Copy link
Author

@jt3k did it #370

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants