Xcode9.2でCarthageがエラーになる

環境
macOS High Sierra 10.13.2
Xcode9.2

Realmの勉強をしようとしてCartfileを作ってcarthage updateを実行してみたものの、なぜかエラーになってしまった。

carthage update –platform iOSの場合だとSwiftのバージョンのエラーになる。
carthage update --platform iOS
*** Fetching realm-cocoa
*** Downloading realm-cocoa.framework binary at "v3.0.2"
*** Skipped installing realm-cocoa.framework binary due to the error:
"Incompatible Swift version - framework was built with 4.0.2 (swiftlang-900.0.69.2 clang-900.0.38) and the local version is 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2)."

no-use-binariesオプションをつけるとDeveloperToolのパスが違うというエラーになった。
carthage update --platform iOS --no-use-binaries
*** Fetching realm-cocoa
*** Checking out realm-cocoa at "v3.0.2"
*** xcodebuild output can be found in /var/folders/fc/v8sh7c913pg_vrz149mkcxfw0000gn/T/carthage-xcodebuild.GMkcIK.log
A shell task (/usr/bin/xcrun xcodebuild -project /Users/naoyuki/Documents/git/ToDo/Carthage/Checkouts/realm-cocoa/Realm.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

ネットで調べた所、Xcodeのパスに問題があるっぽい。
【メモ】Xcode9ビルドでCarthage経由で導入したライブラリに関してswift version errorが発生

xcode-select -pを実行すると次のパスになっていた。
/Library/Developer/CommandLineTools
これをXcodeのパスに変更。
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
xcode-select -p
/Applications/Xcode.app/Contents/Developer

改めてcarthage updateを実行すると今度はうまくいった。
carthage update --platform iOS --no-use-binaries
*** Fetching realm-cocoa
*** Checking out realm-cocoa at "v3.0.2"
*** xcodebuild output can be found in /var/folders/fc/v8sh7c913pg_vrz149mkcxfw0000gn/T/carthage-xcodebuild.rwc5nk.log
*** Building scheme "Realm" in Realm.xcworkspace
*** Building scheme "RealmSwift" in Realm.xcworkspace

Hatena Blogが新規登録ができなくなって、そのうちサービス終了しそうなので、今後はこちらのブログに書いていく予定。

旧はてなブログ

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です