macOSMedium

Xcode License Error: How to Accept the License Agreement on Mac

This article explains why the Xcode license error occurs on macOS and provides several proven ways to fix it, including automatic acceptance via Terminal and GUI methods.

Updated at February 17, 2026
5-10 min
Easy
FixPedia Team
Применимо к:Xcode 14.0+macOS 12.0+Command Line Tools for Xcode

What the Xcode License Error Means

The error "You have not agreed to the Xcode license agreements" (or its Russian-language variant) appears when attempting to use Xcode, Command Line Tools (xcodebuild, clang, git, and others) on macOS. The system blocks execution, requiring you to accept Apple's license agreement. Typical scenarios include:

  • Running xcodebuild in the terminal.
  • Using git after installing Xcode.
  • Building projects via make or cmake.
  • Launching Xcode from the App Store or Dock.

The full error message:

xcodebuild: error: You have not agreed to the Xcode license agreements. Please open Xcode to accept the license agreement, or run `sudo xcodebuild -license` to view and accept the license agreements from the command line.

Causes

  1. Initial Xcode or Command Line Tools Installation
    After installation, the license is not accepted automatically. Explicit confirmation is required.
  2. macOS or Xcode Update
    After a major system update (e.g., from macOS Monterey to Ventura) or an Xcode update, the license agreement may reset.
  3. Running Tools Without a Graphical Interface
    On servers, in Docker containers, or via SSH, Xcode does not launch in a GUI, so the license cannot be accepted interactively.
  4. Corrupted License Cache
    Rarely, the license file in /Library/Developer/CommandLineTools/ or ~/Library/Developer/ may become corrupted.
  5. Using Outdated Command Line Tools
    If old tools remain in the system after an Xcode update, they may conflict.

Method 1: Accept License via Terminal (Primary)

This is the fastest and most universal method, working even without a graphical interface.

  1. Open Terminal
    Use Spotlight (Cmd+Space → type "Terminal") or find the app in Applications → Utilities.
  2. Run the license acceptance command
    Enter:
    sudo xcodebuild -license
    

    Press Enter. The system will prompt for the administrator password (characters are not displayed—type blindly).
  3. Scroll Through the License Agreement
    Press Space to scroll through the text until the end. After the line appears:
    By typing 'agree' you are agreeing to the terms of the software license agreements.
    

    Type agree and press Enter.
  4. Verify the Result
    Run:
    xcodebuild -version
    

    If the output shows the Xcode version (e.g., Xcode 15.0), the error is resolved.

⚠️ Important: The sudo command requires administrator privileges. Ensure your account has sudo permissions.

Method 2: Accept via Xcode's Graphical Interface

If you have GUI access (e.g., on a workstation), you can accept the license through the Xcode app itself.

  1. Launch Xcode
    Find Xcode in Launchpad or via Spotlight. On first launch, a window with the license agreement appears.
  2. Accept the License
    Click Agree in the bottom-right corner of the window. If the window doesn't appear, go to the menu:
    Xcode → Settings → Locations → Command Line Tools
    

    Select the latest tools version and close settings—Xcode may prompt to accept the license.
  3. Restart Terminal
    After accepting the license, close and reopen Terminal for changes to take effect.

Method 3: Force Acceptance for Automation (CI/CD)

In environments without user input (e.g., GitHub Actions, Jenkins), use non-interactive mode.

  1. Run the command with automatic agreement
    sudo xcodebuild -license accept
    

    This command accepts the license without scrolling through the text. Works in Xcode 13+.
  2. For Older Xcode Versions
    If -license accept is unavailable, use:
    sudo xcodebuild -license < <(echo agree)
    

    This simulates typing agree in interactive mode.
  3. Check in a Script
    Add to your CI pipeline:
    #!/bin/bash
    if ! xcodebuild -checkFirstLaunchStatus 2>/dev/null; then
      sudo xcodebuild -license accept
    fi
    

    The -checkFirstLaunchStatus command checks if the license is accepted (available in Xcode 14+).

Method 4: Reinstall Command Line Tools

If the error persists after accepting the license, the tools themselves may be corrupted.

  1. Remove Current Command Line Tools
    sudo rm -rf /Library/Developer/CommandLineTools
    
  2. Reinstall
    xcode-select --install
    

    Or via softwareupdate:
    softwareupdate --install -a
    
  3. Accept the License
    After installation, repeat Method 1.

Prevention

  • After updating macOS/Xcode, immediately accept the license via terminal to avoid CI/CD disruptions.
  • In deployment scripts, add automatic license acceptance (Method 3) at the beginning.
  • For servers, install Xcode or Command Line Tools from a .pkg package and immediately run sudo xcodebuild -license accept.
  • Regularly check license status in automated environments:
    xcodebuild -checkFirstLaunchStatus || echo "License not accepted"
    

Additional Nuances

Error in Docker Containers

If you're building a macOS-based image (e.g., for testing), add to your Dockerfile:

RUN xcodebuild -license accept

This prevents build failures on first Xcode use.

Multiple Xcode Versions

With multiple Xcode versions installed (e.g., via xcode-select), accept the license for each:

sudo xcodebuild -license -firstLaunch  # For active version
sudo xcode-select -s /Applications/Xcode_14.3.app/Contents/Developer
sudo xcodebuild -license -firstLaunch  # For second version

sudo Permissions Issues

If sudo xcodebuild -license fails with permission errors, check:

sudo -v  # Refreshes sudo cache
dscl . -read /Groups/admin GroupMembership $USER  # Checks if user is in admin group

License Acceptance Logging

To confirm the license is accepted, check the file:

cat /var/db/.AppleSetupDone  # If file exists, setup is complete

However, the primary indicator is successful output from xcodebuild -version.

Compatibility with Older macOS

On macOS 10.15 (Catalina) and earlier, the -license accept flag may be unavailable. Use interactive mode or update Xcode to version 13+.

Recovery After Failure

If the terminal hangs while scrolling the license, press Ctrl+C and retry the command. Sometimes this helps:

sudo xcodebuild -license < /dev/null

This skips interactive mode but may not work in newer versions.

Conclusion

The Xcode license error is a common issue after installation or updates, but it's resolved with a single command in the terminal. Key points:

  • Use sudo xcodebuild -license for interactive acceptance.
  • In automated environments, use sudo xcodebuild -license accept.
  • For frequent issues, check Command Line Tools integrity.

These methods cover 99% of cases on macOS 12+ with Xcode 14+. If the problem persists, verify Xcode is installed correctly and your account has administrator privileges.

F.A.Q.

Why does the Xcode license error occur after a macOS update?
Can the Xcode license be automatically accepted in CI/CD scripts?
What to do if the sudo xcodebuild -license command doesn't work?
Does the Xcode license error affect Homebrew or other package managers?

Hints

Open Terminal
Execute the license acceptance command
Scroll through the license agreement
Verify the issue is resolved

Did this article help you solve the problem?

FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community