Skip to content

Commit

Permalink
Merge pull request #21 from jdx/xcode-fixes
Browse files Browse the repository at this point in the history
Fix the documentation for Xcode
  • Loading branch information
pepicrft authored Jan 18, 2024
2 parents 43cc4c6 + a7cc3f1 commit 3491836
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions ide-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,32 @@ Alternatively, you may be able to get tighter integration with a direnv extensio

## Xcode

Xcode projects can system commands from script build phases and schemes. Since Xcode doesn't source your shell profile the tool versions pinned by your project's Mise configuration file are not automatically resolved through the `$PATH` environment variable.
To work around this, you can use the `mise x`:
Xcode projects can run system commands from script build phases and schemes. Since Xcode sandboxes the execution of the script using the tool `/usr/bin/sandbox-exec`, don't expect Mise and the automatically-activated tools to work out of the box. First, you'll need to add `$(SRCROOT)/.mise.toml` to the list of **Input files**. This is necessary for Xcode to allow reads to that file. Then, you'll need to run your commands through the `mise x` command:

```bash
# Add Mise to the PATH
export PATH="$HOME/.local/bin/bin:$PATH"

# -C ensures that Mise loads the configuration from the Mise configuration
# file in the project's root directory.
mise x -C $SRCROOT swiftlint
```

Note that the `-C` flag ensures that Mise will use the project's root directory, where the Mise configuration file lives, as the working directory for the command. Note that in schemes pre and post action scripts, you'll have to enable "Provide build settings from" to inherit the `$SRCROOT` environment variable.
If you don't want to prefix your commands with `mise x -C $SRCROOT`, you can add the shims directory to the `$PATH` environment variable:

```bash
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/.local/share/mise/shims:$PATH"

mise reshim -C $SRCROOT
swiftlint
```


::: tip NOTE
The `mise reshim` command is important to ensure mise creates shims for the tools and versions specified in the project's mise configuration file. Otherwise the script might end up using other versions of the tools.
:::


## [YOUR IDE HERE]

Expand Down

0 comments on commit 3491836

Please sign in to comment.