yonaskolb / Mint

A package manager that installs and runs executable Swift packages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The mint command can not used in Xcode Run script phase (Mac 11.1 Xcode 12.4 )

sunnyweekday opened this issue · comments

commented

Hard ware: MacBook Pro 13 M1 Chip
System Version: Mac OS 11.1
Xcode version:12.4

It was build fail when add "mint run swiftlint" script by Xcode Run script phase.
The erros msg is:

Script-CC67A95425CFAF5700F12F11.sh: line 3: mint: command not found
Command PhaseScriptExecution failed with a nonzero exit code

The demo project is attached.

BigWord.zip

You could try the absolute path to mint to see if it's a $PATH issue? (run which mint to get the path). I have successfully run mint in build scripts.

It seems that the cause is that $PATH does not contain /opt/homebrew/bin in Xcode's Run Script.

I added the following code before running mint.

## begin
if [ `uname -m` == 'arm64' ] && [ -d /opt/homebrew/bin/ ]; then
  export PATH=/opt/homebrew/bin:$PATH
fi
## end

mint run swiftlint

Then the "mint: command not found" error no longer occurs.

However, I still get the error 🌱 swiftlint package not found and I can't execute the command with mint.

commented

Did you find a solution to this problem?

commented

I resolved this by use the follow script :
export PATH="/opt/homebrew/bin/:$PATH"
mint run swiftlint

commented

Ok, I used your approach, it works. I just made a small change usingxcrun --sdk macosx mint to start Mint

commented

Is there a way to set the PATH system-wide ?
I don't understand why we need to update the PATH during the script phase.
For example my .zshrc already has the /opt/homebrew/bin/ PATH in the $PATH variable but still... Xcode throws this command not found error.

I had the same problem. After using another install method other than homebrew, everything works great. Lets try:

$ git clone https://github.com/yonaskolb/Mint.git
$ cd Mint
$ make
commented

For those who wants to continue using mint from homebrew, you can symlink your brew's mint to /usr/local/bin/mint, make sure there is no existing mint folder in /usr/local/bin.

sudo ln -s /opt/homebrew/bin/mint /usr/local/bin/mint

source: https://stackoverflow.com/a/71674601

For those who wants to continue using mint from homebrew, you can symlink your brew's mint to /usr/local/bin/mint, make sure there is no existing mint folder in /usr/local/bin.

sudo ln -s /opt/homebrew/bin/mint /usr/local/bin/mint

source: https://stackoverflow.com/a/71674601

Thanks! It's works!