TL;DR
Carthage内部のコマンドで参照されるxcodebuild
のバージョンを、対象プロジェクトが対応しているXcodeのバージョンに切り替えるとエラーがなくなりました。
$ sudo xcode-select -switch /Applications/Xcode_7.3.1.app/Contents/Developer
実行後は切り替わっているか確認する。
$ xcode-select -p
/Applications/Xcode_7.3.1.app/Contents/Developer
設定が残り続けるので用が済んだら戻しておくと安心そうです。
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
エラーの詳細
今回は、Xcode8をインストールした状態でXcode7のプロジェクトをCarthageを使って依存解決しようとしてエラーが出ました。
$ carthage update --platform iOS
*** xcodebuild output can be found in /var/folders/pc/k0zgdyzj7vq_c9vcdngw4pr00000gn/T/carthage-xcodebuild.9dVuv2.log
*** Building scheme "Alamofire iOS" in Alamofire.xcworkspace
2016-10-23 22:30:58.726 xcodebuild[55081:11358256] WARNING: Failed to load plugin at path: "/Users/hoge/Library/Application Support/Developer/Shared/Xcode/Plug-ins/BBUDebuggerTuckAway.xcplugin", skipping. Error: Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/Users/hoge/Library/Application Support/Developer/Shared/Xcode/Plug-ins/BBUDebuggerTuckAway.xcplugin/Contents/MacOS/BBUDebuggerTuckAway): no suitable image found. Did find:
/Users/hoge/Library/Application Support/Developer/Shared/Xcode/Plug-ins/BBUDebuggerTuckAway.xcplugin/Contents/MacOS/BBUDebuggerTuckAway: mmap() error 1 at address=0x11CFC7000, size=0x0000D000 segment=__TEXT in Segment::map() mapping /Users/hoge/Library/Application Support/Developer/Shared/Xcode/Plug-ins/BBUDebuggerTuckAway.xcplugin/Contents/MacOS/BBUDebuggerTuckAway" UserInfo={NSLocalizedFailureReason=The bundle is damaged or missing necessary resources., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Users/hoge/Library/Application Support/Developer/Shared/Xcode/Plug-ins/BBUDebuggerTuckAway.xcplugin/Contents/MacOS/BBUDebuggerTuckAway, NSDebugDescription=dlopen_preflight(/Users/hoge/Library/Application Support/Developer/Shared/Xcode/Plug-ins/BBUDebuggerTuckAway.xcplugin/Contents/MacOS/BBUDebuggerTuckAway): no suitable image found. Did find:
/Users/hoge/Library/Application Support/Developer/Shared/Xcode/Plug-ins/BBUDebuggerTuckAway.xcplugin/Contents/MacOS/BBUDebuggerTuckAway: mmap() error 1 at address=0x11CFC7000, size=0x0000D000 segment=__TEXT in Segment::map() mapping /Users/hoge/Library/Application Support/Developer/Shared/Xcode/Plug-ins/BBUDebuggerTuckAway.xcplugin/Contents/MacOS/BBUDebuggerTuckAway, NSBundlePath=/Users/hoge/Library/Application Support/Developer/Shared/Xcode/Plug-ins/BBUDebuggerTuckAway.xcplugin, NSLocalizedDescription=The bundle “BBUDebuggerTuckAway” couldn’t be loaded because it is damaged or missing necessary resources.}
...
** CLEAN FAILED **
The following build commands failed:
Check dependencies
(1 failure)
** BUILD FAILED **
...
上記のログ上部にある/var/folders/pc/****
というログにアクセスすると、以下のコマンドがCarthage内部で実行されていることが分かります。
/usr/bin/xcrun xcodebuild
使用されるxcrun
自体のパスを切り替える変数はCarthageにないようなので、記事冒頭に書いたxcode-select
でxcrun
が呼び出すxcodebuild
のパスを切り替えるのが良さそうです。