【Swift/Carthage】Error:「failed with exit code 72:xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH」の解決方法!

この記事からわかること
- Swift/Carthageでライブラリ導入時に発生したエラーの解決法
- Error:failed with exit code 72:xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH"の原因
- Xcodeの実行パスの変更方法
index
[open]
\ アプリをリリースしました /
環境
- Xcode:14.2
- Carthage:0.39.0
failed with exit code 72:xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH
Carthageを使用してライブラリを導入する以下のコマンドを実行した際にエラーが発生しました。
$ carthage update --platform iOS
発生したエラー
*** Fetching Alamofire
*** Checking out Alamofire at "5.7.1"
*** xcodebuild output can be found in /var/folders/wh/vtp248lx2fs00q111ngnmc2h0000gn/T/carthage-xcodebuild.TwpGpA.log
*** Skipped downloading Alamofire binary due to the error:
"Bad credentials"
A shell task (/usr/bin/xcrun xcodebuild -workspace /Users/ユーザー名/Desktop/TestCarthage/Carthage/Checkouts/Alamofire/Alamofire.xcworkspace 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
同時に発生していた「Skipped downloading Alamofire binary due to the error:"Bad credentials"」の解決方法は以下を参考にしてください。
エラーの原因
failed with exit code 72:xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH
はCarthageからGitHubを経由してライブラリをインストールする際にターミナルにてXcodeが指定されていないまたは実行パスがおかしいことで発生するようです。
failed with exit code 72:xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH
解決方法
私の場合はターミナルからのXcodeの実行パスを変更することができました。
解決方法
ターミナルからのxcode-selectの実行パスを/Applications/Xcode.app/Contents/Developerに変更する
まずはxcode-select --print-path
コマンドで現在の実行パスを見てみます。私の場合は/Library/Developer/CommandLineTools
になっていました。
$ xcode-select --print-path
/Library/Developer/CommandLineTools
なので実行パスを変更する以下のコマンドを実行します。
$ sudo xcode-select --switch /Applications/Xcode.app
パスが変更されました・
$ xcode-select --print-path
/Applications/Xcode.app
これで再度実行することで問題なくインストールすることができました。
$ carthage update --platform iOS
ご覧いただきありがとうございました。