Skip to content

Instantly share code, notes, and snippets.

@zoltan-magyar
Last active May 10, 2026 12:19
Show Gist options
  • Select an option

  • Save zoltan-magyar/be846eb36cf5ee33c882ef5f932b754b to your computer and use it in GitHub Desktop.

Select an option

Save zoltan-magyar/be846eb36cf5ee33c882ef5f932b754b to your computer and use it in GitHub Desktop.
Xcode Claude Code integration with third-party APIs

Setting Up Xcode Claude Code with Third-Party API Endpoints

This guide explains how to configure Xcode's built-in Claude Code integration to work with third-party API endpoints instead of the official Anthropic API. You need macOS 26.2+ and Xcode 26.3+ for the Claude Code integration.

Step 1: Install Claude Code component in Xcode

You need to first install Xcode's own Claude Code instance, with its own Claude Code binary.

Xcode Settings -> Intelligence -> Anthropic -> Claude Agent -> press Get button

Step 2: Bypass the Authentication UI

Xcode normally requires signing in through the UI with an Anthropic account or API key and doesn't offer any bypass. Even if the Xcode internal claude can use your third-party endpoint Xcode won't send any query because YoU ARe NOt LOgGeD IN. To bypass this when using a third-party endpoint, set a placeholder API key override, which you cannot do through the UI:

defaults write com.apple.dt.Xcode IDEChatClaudeAgentAPIKeyOverride ' '

This tricks Xcode into thinking authentication is configured, allowing prompts to be sent.

Step 3: Configure the Third-Party Endpoint

Create the settings directory if it doesn't exist, this is what the Xcode Claude instance uses, it is basically your average .claude directory:

mkdir -p ~/Library/Developer/Xcode/CodingAssistant/ClaudeAgentConfig

Create or edit the settings file:

nvim ~/Library/Developer/Xcode/CodingAssistant/ClaudeAgentConfig/settings.json

Add the following minimal configuration:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your-auth-token-here",
    "ANTHROPIC_BASE_URL": "https://your-api-endpoint.example.com/path"
  }
}

Replace:

  • your-auth-token-here with your API authentication token
  • https://your-api-endpoint.example.com/path with your endpoint URL

Step 4: Restart Xcode

Quit and relaunch Xcode. Claude Code should now work with your third-party endpoint.

Optional: Self-Signed or Internal CA Certificates

If your endpoint uses a self-signed or internal CA certificate, you need to set environment variables before Xcode launches. The NODE_EXTRA_CA_CERTS setting in settings.json does not work because Claude does not really care about long-standing issues and is insistent on closing issues after 60 days. Setting this in the env field of the settings.json will not work for the aformentioned reason.

Launch Agent

Create the Launch Agent file:

nano ~/Library/LaunchAgents/com.xcode-claude-environment.plist

Add the following content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>Xcode Claude Environment</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/bash</string>
        <string>-c</string>
        <string>launchctl setenv NODE_EXTRA_CA_CERTS /path/to/your/ca-cert.pem; launchctl setenv SSL_CERT_FILE /path/to/your/ca-cert.pem</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

Load the Launch Agent:

launchctl load ~/Library/LaunchAgents/com.xcode-claude-environment.plist

Important: Log out and back in (or restart) for the environment variables to take effect for GUI applications.

Additional Settings

Because model selection is not available with this 'hack', and your company is most likely paying for your tokens, you can set the preferred model to opus with the following command:

defaults write com.apple.dt.Xcode IDEChatClaudeAgentModelConfigurationAlias 'sonnet'

Troubleshooting

Check Debug Logs

Claude Code writes debug logs to:

~/Library/Developer/Xcode/CodingAssistant/ClaudeAgentConfig/debug/

Look for [ERROR] entries, particularly SSL/connection errors.

Common Errors

"self signed certificate in certificate chain"

  • Your endpoint uses a certificate not trusted by node

Login prompt still appears

  • Verify the API key override is set:
    defaults read com.apple.dt.Xcode IDEChatClaudeAgentAPIKeyOverride
  • Should return a space character

Request hangs indefinitely

  • Check if ANTHROPIC_BASE_URL is correct in settings.json
  • Verify your endpoint is reachable

Reset Configuration

Remove the API key override:

defaults delete com.apple.dt.Xcode IDEChatClaudeAgentAPIKeyOverride

Unload the Launch Agent:

launchctl unload ~/Library/LaunchAgents/com.xcode-claude-environment.plist
rm ~/Library/LaunchAgents/com.xcode-claude-environment.plist
@ipochi
Copy link
Copy Markdown

ipochi commented Apr 14, 2026

What if you dont have

"ANTHROPIC_AUTH_TOKEN": "your-auth-token-here",

and have github copilot claude models routed through litellm proxy. The auth workflow would be the github auth/device code.

Would it work with just the "ANTHROPIC_BASE_URL" ? Replicating the same setup that i have for claude code ?

It works !!!

Additional note for LiteLLM proxy users (e.g. GitHub Copilot-hosted Anthropic models):

Set ANTHROPIC_AUTH_TOKEN to your LiteLLM master key — not a placeholder space. The Claude agent binary validates the key format before connecting, and the token is actually sent to your proxy as the auth header.

  {
    "env": {
      "ANTHROPIC_AUTH_TOKEN": "<your-litellm-master-key>",
      "ANTHROPIC_BASE_URL": "http://localhost:4000"
    }
  }

Make sure your LiteLLM proxy is running before launching Xcode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment