10
2

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で「DEVELOPER_DIR」に指定するパス

Last updated at Posted at 2020-09-25

はじめに

ターミナルでどのXcodeを使うか指定するとき、以下の2パターンを見かけますが、みなさんはどちらで指定しているでしょうか。
また、同じ挙動になるかご存知でしょうか。

DEVELOPER_DIRの指定パス
# 1
$ export DEVELOPER_DIR=/Applications/Xcode_12.app/Contents/Developer

# 2
$ export DEVELOPER_DIR=/Applications/Xcode_12.app

私は先日まで知りませんでした。

結論

結論から言うと、1も2も同様の挙動になるので、どちらで指定しても問題ありません。

man xcode-select で解説されています。

xcode-selectのmanualの抜粋
EXAMPLES
       xcode-select --switch /Applications/Xcode.app/Contents/Developer
          Select /Applications/Xcode.app/Contents/Developer as the active developer directory.

       xcode-select --switch /Applications/Xcode.app
          As above, selects /Applications/Xcode.app/Contents/Developer as the active developer directory. The Developer content directory is automatically inferred by xcode-select.

DEVELOPER_DIR の名前通り「Developer」フォルダを指定すべきですが、「Xcode.app」のパスを指定した場合は自動で「Developer」フォルダが推測されます。

おまけ:「DEVELOPER_DIR」と「xcode-select」について

コマンドラインで使うXcodeを指定するには、 DEVELOPER_DIR 環境変数をエクスポートする方法と、 xcode-select コマンドで指定する方法の2通りあります。

以下の記事で取り上げた通り、私は前者の方法を使っています。
https://qiita.com/uhooi/items/29664ecf0254eb637951#xcodeの選択不要

おまけ:XcodeのCLIツールの説明はmanが詳しい

xcode-select コマンド以外にも、 xcrunxcodebuild などのコマンドはWeb上に情報が多くありません。
man コマンドによる説明が一番詳しい公式ドキュメントといっても過言ではないので、覚えておくと有用です。

おわりに

「DEVELOPER_DIR」に指定するパスは、「Developer」フォルダと「Xcode.app」のパスのどちらでもいいことがわかりました。
つまりどちらを指定するかは好みです。

私は1で指定していましたが、短いほうがスッキリするので最近は2で指定することが多いです。

10
2
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
10
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?