📅  最后修改于: 2023-12-03 14:48:37.847000             🧑  作者: Mango
This error message occurs when the command-line tools required by Xcode are not properly configured or installed. It indicates that the active developer path is invalid or missing.
In this article, we will discuss the possible causes of this error and provide solutions to fix it.
There are several reasons why you might encounter this error:
Xcode Not Installed: You need to have Xcode installed on your system for the command-line tools to work properly. If Xcode is not installed or not updated to the latest version, this error may occur.
Command-Line Tools Not Installed: Even if Xcode is installed, you still need to install the command-line tools separately. If they are not installed or not properly configured, you may encounter this error.
Xcode Path Misconfiguration: The active developer path may be incorrectly set or pointing to the wrong location. This can happen when Xcode is moved or updated to a different location on your system.
Here are some solutions to resolve the 'xcrun: error: invalid active developer path' error:
Ensure that you have Xcode installed on your system and it is updated to the latest version. You can download and install Xcode from the App Store.
After installing or updating Xcode, make sure to install the command-line tools. Open Terminal and enter the following command:
xcode-select --install
This command will prompt you to install the command-line tools. Follow the on-screen instructions to complete the installation.
If Xcode is already installed but the active developer path is incorrect, you can set it manually using the following command:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
Replace the path "/Applications/Xcode.app/Contents/Developer" with the actual path of your Xcode installation if it is different.
If none of the above solutions work, you can try resetting the command-line tools by running the following command:
sudo xcode-select --reset
This command will reset the active developer path and prompt you to select the developer directory. Choose the appropriate Xcode installation directory.
The 'xcrun: error: invalid active developer path (Applications/Xcode.app/Contents/Developer)' error indicates that there is a problem with the Xcode installation or the command-line tools configuration. By following the solutions provided in this article, you should be able to resolve the issue and continue working with Xcode and related development tools without any problems.