9

I am using a setup on Xcode that runs the following script for SwiftLint

if which $PATH/swiftlint >/dev/null; then
$PATH/swiftlint
elif which $HOME/.brew/bin/swiftlint >/dev/null; then
$HOME/.brew/bin/swiftlint
elif which ~/Softwares/homebrew/bin/swiftlint >/dev/null; then
~/Softwares/homebrew/bin/swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

I am unable to use pods or brew.

To make SwiftLint available I added the following to my path by using vim ~/.bash_profile

export PATH
export PATH=$PATH:/Users/me/Documents/SwiftLint

and I can now access SwiftLint everywhere through the command line.

However, Xcode still displays the message that SwiftLint is not installed.

I can't use another method to install Swiftlint or change the script. I guess there is a problem with my export path - what is it?

Flexicoder
  • 8,251
  • 4
  • 42
  • 56
StackUnderflow
  • 107
  • 1
  • 4

2 Answers2

11

When running scripts, .bash_profile will not be considered. I would just prepend your script like this:

if test -d "${HOME}/Documents/SwiftLint"; then
  PATH="${HOME}/Documents/SwiftLint:${PATH}"
fi

export PATH

if ! which swiftlint >/dev/null 2>&1; then
    echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" >&2
fi
herzi
  • 774
  • 6
  • 18
1

You could just export the path to system-wide variables.

Steps to do

  1. open Terminal
  2. run command open .zshrc
  3. add export PATH="${HOME}/Documents/SwiftLint:${PATH}"
  4. Save and close
Mohamed Shaban
  • 2,263
  • 1
  • 15
  • 23