LogoLogo
Packmind CloudChangelogGet supportJoin Slack
  • 👋Welcome!
  • 🪐Manage spaces
  • 🔐Security and data
  • 🐞Troubleshooting guides
  • 🚀First steps
    • Enable and configure AI
    • Connect your Git platform
  • 📥Capture your coding practices
    • How to create coding practices
    • Review practices in the Inbox
  • 🔍Enforce practices in your code
    • Setup practices detection with the AI Agent
    • Packmind CLI
      • Run with NPM
      • Run with Docker
      • SonarQube Integration
      • Run in Gitlab CI
  • Coding Assistants Integration
  • 👩‍💻Plugins & Integrations
    • IDE Plugins
      • 🚀Packmind's IDE plugins use cases
      • Visual Studio Code
      • Visual Studio
      • JetBrains IDEs
      • Eclipse
      • Xcode
      • Packmind Tech Coach
    • 🔔Get notifications
  • 📖Best practices management
    • Manage your practices
      • Import, copy and export practices
      • Use categories to organize your practices
      • Manage duplications of practices
      • Move all practices from a space to another space
      • Styling with Markdown
      • Multi-file examples on coding practices
    • 📰Scheduler to push practices
  • ↔️API Reference
    • Authentication
    • Documentation
  • ⚙️Account & Settings
    • 👩‍💼Manage users
    • 💵Subscription and Billing
    • 🔓Single Sign-On (SSO) in Packmind
      • Enable SSO for Packmind Cloud
      • Enable SSO for Packmind Self-Hosted
  • 🏠On-Premise version
    • Release notes - Self-Hosted versions
    • Install the Self-Hosted version
      • Migrate from a legacy setup (Mongo 2.x)
    • Connect a SMTP server
    • Authentication
      • Authentication with OpenLDAP
      • Authentication by SSO
      • Authentication with Active Directory
Powered by GitBook
On this page
  • Step 1: Install the Packmind CLI
  • Step 2: Configure your Xcode project
  • Step 3: Allow the script to read your project files

Was this helpful?

  1. Plugins & Integrations
  2. IDE Plugins

Xcode

PreviousEclipseNextPackmind Tech Coach

Last updated 1 month ago

Was this helpful?

You can integrate Packmind CLI in the build phase of your Xcode projects, to get violations of your Packmind practices in your source code.

Due to the limitations offered by Xcode, the experience is limited in comparison with other supported IDEs.

However, the core feature —Detection— is fully available, ensuring you can use Packmind to detect best practices directly within your workflow.

What you'll get is the results of the execution of the Packmind CLI, that will display warnings when it detect violations of your practices.

Step 1: Install the Packmind CLI

You can refer to the dedicated documentation here.

The easiest remains is to install the npm package globally with:

npm install -g packmind-cli

To ensure all is setup correctly, please use

packmind-cli -v

and ensures it returns a proper version number.

Ensure to have at least 1.8.4, as Xcode support was introduced in the version

Step 2: Configure your Xcode project

Directly in your Xcode project, add a custom Build Phase using the '+' button.

We recommend to use bin/zsh as the shell, as it's the standard for MacOS. Note that the first instruction allows the script to load your environment variables and especially the NodeJS executable.

Here is this script shown in the screen:

. ~/.zshrc
cd "${SRCROOT}"
packmind-cli scan --formatters xcode --spaces="Swift,Space 2" --mode onlyChanged
exit 0

Here we use the --spaces="Swift,Space 2" option, but you need to adapt it to your context by adding the name of the space or spaces (separated with a ",") you want to use for the detection.

You can add your API Key in your.zshrcfile, it should contain the following line:

export PACKMIND_API_KEY=<your_api_key>

You can retrieve your API key from the Web interface of Packmind, in the My account > API Key and addons menu.

Based on your context and project's setup, you can adjust this script. What's required is:

  • To be able to run the CLI

  • To load as an environment variable an API Key to authenticate to Packmind.

You can read the CLI documentation to adjust the settings.

Step 3: Allow the script to read your project files

The last step is to ensure the User Script Sandboxing is properly set within the Build Settings.

Select All and Levels and search "sandbox".

You should set the value to No, at least for the Debug phase. Otherwise, you're likely to get errors such as permissions issues to read your current directory.

Now, when you'll build your project, the CLI will be run and displays warnings for the results.

Ensure NodeJS is setup on your MacOS. If not, you can get started with the following link to install .

👩‍💻
Packmind CLI
Node 20