【Swift/Carthage】Error:「Bad credentials」の解決方法!GitHubの認証

この記事からわかること

  • Swift/Carthageライブラリ導入時に発生したエラー解決法
  • ErrorSkipped downloading Alamofire binary due to the error:"Bad credentials"原因
  • GitHubでの認証方法

index

[open]

\ アプリをリリースしました /

みんなの誕生日

友達や家族の誕生日をメモ!通知も届く-みんなの誕生日-

posted withアプリーチ

環境

Skipped downloading Alamofire binary due to the error:"Bad credentials"

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

同時に発生していた「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"はCarthageからGitHubを経由してライブラリをインストールする際に認証が何らかの理由で失敗することで発生するようです。


Skipped downloading Alamofire binary due to the error:
	"Bad credentials"

解決方法

私の場合はGitHubの設定(~/.gitconfig)を変更することで解決することができました。

解決方法

~/.gitconfigにcredential情報を追記した

まずはcatコマンドで中身を見てみます。Gitを使用しているのであれば以下のようにユーザー名とE-メールアドレスが設定されているかと思います。

$ cat ~/.gitconfig       
[user]
	name = UserName
	email = sample@sample.com

ここに以下の情報を追記します。


[credential]
    helper = osxkeychain
[credential "https://github.com"]
    username = GitHubのユーザー名

上記の文字の「GitHubのユーザー名」だけ変更し、コピーしてVimを使用してファイルを編集していきます。

おすすめ記事:【Linux】vi(Vim)エディタとは?コマンドモードの切り替え方や使い方

$ vim ~/.gitconfig

開いたら中にペーストして:wqでVimを保存して終了します。

再度中を見て以下のようになっていれば成功です。

$ cat ~/.gitconfig       
[user]
	name = UserName
	email = sample@sample.com
[credential]
    helper = osxkeychain
[credential "https://github.com"]
    username = GitHubのユーザー名

これで再度実行することで問題なくインストールすることができました。

$ carthage update --platform iOS

ご覧いただきありがとうございました。

searchbox

スポンサー

ProFile

ame

趣味:読書,プログラミング学習,サイト制作,ブログ

IT嫌いを克服するためにITパスを取得しようと勉強してからサイト制作が趣味に変わりました笑
今はCMSを使わずこのサイトを完全自作でサイト運営中〜

New Article

index