0

Hello:) I'm trying to implement a new xcode behavior which runs swiftlint's autocorrect on currently open Xcode file. If I run the script from terminal, it works just perfectly, however, if I execute the script through xcodes behaviors, all of the script gets executed except for the swiftlint part (when I tried to print the output to a file, it only outputed an empty line). I did set permission to chmod u+x, so I think it should be okay. Maybe someone could help me figure out what's the reason? I seem to have hit a dead end and can't find anyone who had a similar problem:(

Here's my script:

#!/bin/sh
fileName=$(osascript <<END
tell application "Xcode"
    set t to name of front window
    set o to offset of " — " in t
    if o > 0 then set t to text 1 thru (o - 1) of t
    return t
end tell
END)

fullPath=$(find . -name "$fileName")
swiftlint autocorrect --path $fullPath

This uses AppleScript to extract currently active file from Xcode and then runs swiftlint on it.

Thanks in advance

sponkau
  • 23
  • 4

1 Answers1

0

Funny how I found the solution a few minutes after I posted the question.

The problem was that Xcode didn't recognize swiftlint command, so I replaced it with full path to it and it worked!:)

sponkau
  • 23
  • 4