fork-dev / Tracker

Bug and issue tracker for Fork for Mac
505 stars 12 forks source link

Custom action for Xcode projects #316

Closed artemnovichkov closed 5 years ago

artemnovichkov commented 6 years ago

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

DanPristupov commented 6 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.

artemnovichkov commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

artemnovichkov commented 6 years ago

@jt3k did it https://github.com/ForkIssues/Tracker/issues/370