Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

今まで 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 に組み込みやすいかとおもいます。

repro
世界59か国6,500以上の導入実績を持つCE(カスタマーエンゲージメント)プラットフォーム「Repro(リプロ)」を提供
https://repro.io/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした