問題
こちらの記事を参考にCursor(VSCode)でiosアプリの開発環境を整えていた。しかし、SweetPad拡張機能を入れたところ、エラーが発生。
No Xcode scheme was found.
Select the workspace that has the Xcode project to use SweetPad.
この状態でBuildしても当然ながらうまくいかない。ログを見ると、以下のエラーが出ていた。
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
原因
macOSにはXcodeや開発ツールを探す場所として認識するディレクトリ=「アクティブデベロッパディレクトリ」という概念がある。アクティブデベロッパディレクトリがCommand Line Tools(CLT)のみに設定されているとうまくいかない。
以下のコマンドでアクティブデベロッパディレクトリに設定パスを確認してみる。
xcode-select -p
CLTが選択されている場合は
/Library/Developer/CommandLineTools
となる。
解決策
アクティブデベロッパディレクトリを以下のコマンドでXcodeに切り替えれば良い。
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
パスが
/Applications/Xcode.app/Contents/Developer
のようになっていればOK。
参考