294

I am getting this error while building the SwiftJSON framework to the Some Xcode project through Carthage Dependency Manager.

Sivaramaiahs-Mac-mini:GZipDemoApp vsoftMacmini5$ carthage update --platform iOS

*** Fetching GzipSwift

*** Fetching SwiftyJSON

*** Checking out GzipSwift at "3.1.1"

*** Downloading SwiftyJSON.framework binary at "3.1.3"

*** xcodebuild output can be found in /var/folders/7m/y0r2mdhn0f16zz1nlt34ypzr0000gn/T/carthage-xcodebuild.apLXCc.log

A shell task (/usr/bin/xcrun xcodebuild -project /Users/vsoftMacmini5/Desktop/GZipDemoApp/Carthage/Checkouts/GzipSwift/Gzip.xcodeproj CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES -list) failed with exit code 72:

xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH

3 Answers 3

896
+50

I solved that problem by setting the Command Line Tools in Xcode. Go to:

Xcode > Preferences > Locations

And select the command line tool from the dropdown. If you have only one version of Xcode installed, there should be only one option. If you have several versions of Xcode, then you must choose the one you need.

Update (added image for reference)

enter image description here

5
  • 9
    It didnt even have anything set by default for me when I looked at that setting until I set it to xCode X
    – NukeouT
    Commented Jan 6, 2019 at 1:36
  • 4
    Thank you, I don't know why it was unselected, maybe after install carthage, and selecting my version like in the image. Commented Jan 15, 2019 at 15:09
  • 1
    Thank you for posting this. I wonder if it's an issue with people on brand new machines. Commented Apr 2, 2019 at 18:19
  • 2
    Had to do this for 10.3 on Catalina.
    – Chris
    Commented Sep 12, 2019 at 21:49
  • Thank you, my setup : Catalina 10.15.7 with Xcode 10.1
    – Sen-He Lee
    Commented Nov 12, 2020 at 7:07
116

The simplest fix is from CLI:

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

(this should be path to your Xcode.app)

By the way this can happen even if you have only one version of Xcode . It happens when you instal homebrew before the first Xcode installation (which makes sense because you may want to install Xcode through mas install 497799835 and mas needs homebrew).

4
  • sudo xcode-select -s /Applications/Xcode.app/Contents/Developer; sudo xcode-select -s /Library/Developer/CommandLineTools Commented Jan 9, 2020 at 22:46
  • This worked for me
    – Prayag
    Commented Sep 23, 2023 at 5:25
  • 1
    This should be the selected answer. This is correct and tells you why it's correct. Commented Oct 17, 2023 at 18:30
  • thanks worked for my flutter project too... Commented Apr 11 at 10:26
3

Following command worked for me

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Mar 7, 2022 at 10:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.