47
43

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

環境変数を使用して Xcode のバージョンを切り替える

Posted at

今まで xcode-select を使って、

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

のように Xcode のバージョンを切り替えていたのですが、xcode-select の man ページを見ていたら環境変数 DEVELOPER_DIR で一時的に切り替えられることが書いてありました。

$ xcodebuild -version
Xcode 7.3.1
Build version 7D1014

$ DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer xcodebuild -version
Xcode 8.0
Build version 8S201h

$ xcodebuild -version
Xcode 7.3.1
Build version 7D1014

export を使って環境変数を設定すれば、シェルを閉じるまで切り替えることができます。

$ export DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer
$ xcodebuild -version
Xcode 8.0
Build version 8S201h
$ clang -v
Apple LLVM version 8.0.0 (clang-800.0.38)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

DEVELOPER_DIR を使えば sudo xcode-select -s xxxx とは違ってパスワードの入力が催促されることがないので、Jenkins などの CI に組み込みやすいかとおもいます。

47
43
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
47
43

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?