30
23

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 の Build Settings をコマンドで調べる方法(xcodebuild -showBuildSettings | grep 変数名)

Last updated at Posted at 2016-02-19

こんにちは❗️😊

Xcode の Build Settings をコマンドで調べる方法を紹介します。
xcodebuild コマンドの -showBuildSettings オプションと grep コマンドを使います。

ググると同様の記事はいくつかありましたが__細かく書かれた記事が見当たらなかったため__いくつかの実行例をまじえて書きます🙋
すでに似たような記事があればスルーしてください🙏

すぐにでもピンポイントで調べたい方は「PATH だけを調べたい」を参照してください🙇

xcodebuild コマンドとは

その名のとおり Xcode の Project と Workspace をビルドするコマンドです。
ターミナルを起動して $ xcodebuild -usage を実行すると Usage: が出力されます。1

Usage: xcodebuild [-project <projectname>] [[-target <targetname>]...|-alltargets] [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...
       xcodebuild [-project <projectname>] -scheme <schemeName> [-destination <destinationspecifier>]... [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...
       xcodebuild -workspace <workspacename> -scheme <schemeName> [-destination <destinationspecifier>]... [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...

オプション

上記のとおりこれだけあります。

  • -project
  • -target
  • -alltargets
  • -configuration
  • -arch
  • -sdk
  • -showBuildSettings
  • -scheme
  • -workspace

追記: ほかにもたくさんあることがわかったのでこちらに書きました。
http://qiita.com/Martha/items/412f0678c424f35b3c0e

前提

Pancake.xcodeprojPancake フォルダにあるという前提で説明します。
xcodebuild コマンドはプロジェクトのルートで実行するため Pancake フォルダに移動します。

$ cd Pancake

まずはシンプルに

$ xcodebuild -showBuildSettings

僕の環境では 360 行ほど出力されます😅

Build settings for action build and target pancake:
    ACTION = build
...

条件指定

オプションで条件を指定します。
Target: pancake, Configuration: Release

$ xcodebuild -target pancake -configuration Release -showBuildSettings

ただしこれでも大量に出力されます😐

PATH を含む変数を調べたい

後ろに | grep PATH を追記します。

$ xcodebuild -target PancakeKit -configuration Release -showBuildSettings | grep PATH

さすがに PATH は多いですね😳

ALWAYS_SEARCH_USER_PATHS = NO
CODESIGNING_FOLDER_PATH = /.../Release/PancakeKit.framework/Versions/A
CONTENTS_FOLDER_PATH = PancakeKit.framework/Versions/A
DEFAULT_KEXT_INSTALL_PATH = /Library/Extensions
DOCUMENTATION_FOLDER_PATH = PancakeKit.framework/Versions/A/Resources/English.lproj/Documentation
DWARF_DSYM_FOLDER_PATH = /.../Release
EXCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES = *.nib *.lproj *.framework *.gch *.xcode* *.xcassets (*) .DS_Store CVS .svn .git .hg *.pbproj *.pbxproj
EXECUTABLES_FOLDER_PATH = PancakeKit.framework/Versions/A/Resources/English.lproj
EXECUTABLE_FOLDER_PATH = PancakeKit.framework/Versions/A
EXECUTABLE_PATH = PancakeKit.framework/Versions/A/PancakeKit
FRAMEWORKS_FOLDER_PATH = PancakeKit.framework/Versions/A/Frameworks
INFOPLISTSTRINGS_PATH = PancakeKit.framework/Versions/A/Resources/English.lproj/InfoPlist.strings
INFOPLIST_PATH = PancakeKit.framework/Versions/A/Resources/Info.plist
INSTALL_PATH = @rpath
JAVA_FOLDER_PATH = PancakeKit.framework/Versions/A/Resources/Java
LD_MAP_FILE_PATH = /.../Release/PancakeKit.build/PancakeKit-LinkMap-normal-x86_64.txt
LD_RUNPATH_SEARCH_PATHS =  @executable_path/../Frameworks @loader_path/../Frameworks
LIBRARY_KEXT_INSTALL_PATH = /Library/Extensions
LOCALIZED_RESOURCES_FOLDER_PATH = PancakeKit.framework/Versions/A/Resources/English.lproj
PATH = /Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
PATH_PREFIXES_EXCLUDED_FROM_HEADER_DEPENDENCIES = /usr/include /usr/local/include /System/Library/Frameworks /System/Library/PrivateFrameworks /Applications/Xcode.app/Contents/Developer/Headers /Applications/Xcode.app/Contents/Developer/SDKs /Applications/Xcode.app/Contents/Developer/Platforms
PBDEVELOPMENTPLIST_PATH = PancakeKit.framework/Versions/A/pbdevelopment.plist
PKGINFO_FILE_PATH = /.../Release/PancakeKit.build/PkgInfo
PKGINFO_PATH = PancakeKit.framework/PkgInfo
PLUGINS_FOLDER_PATH = PancakeKit.framework/Versions/A/PlugIns
PRIVATE_HEADERS_FOLDER_PATH = PancakeKit.framework/Versions/A/PrivateHeaders
PRODUCT_SETTINGS_PATH = /.../Pancake/Sources/PancakeKit/Info.plist
PROJECT_FILE_PATH = /.../Pancake/Pancake.xcodeproj
PUBLIC_HEADERS_FOLDER_PATH = PancakeKit.framework/Versions/A/Headers
RECURSIVE_SEARCH_PATHS_FOLLOW_SYMLINKS = YES
SCRIPTS_FOLDER_PATH = PancakeKit.framework/Versions/A/Resources/Scripts
SHARED_FRAMEWORKS_FOLDER_PATH = PancakeKit.framework/Versions/A/SharedFrameworks
SHARED_SUPPORT_FOLDER_PATH = PancakeKit.framework/Versions/A/Resources
SYSTEM_KEXT_INSTALL_PATH = /System/Library/Extensions
UNLOCALIZED_RESOURCES_FOLDER_PATH = PancakeKit.framework/Versions/A/Resources
VERSIONPLIST_PATH = PancakeKit.framework/Versions/A/Resources/version.plist
VERSIONS_FOLDER_PATH = PancakeKit.framework/Versions
XPCSERVICES_FOLDER_PATH = PancakeKit.framework/Versions/A/XPCServices

PATH だけを調べたい(追記)

後ろに | grep -w PATH を追記します。

$ xcodebuild -target PancakeKit -configuration Release -showBuildSettings | grep -w PATH

PATH を含むすべてではなく PATH だけを出力します🤓

PATH = /Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

これができれば次の方法は不要ですが一度記載したので残しておきます。

LD_RUNPATH_SEARCH_PATHS だけを調べたい

後ろに | grep LD_RUNPATH_SEARCH_PATHS を追記します。

$ xcodebuild -target pancake -configuration Release -showBuildSettings | grep LD_RUNPATH_SEARCH_PATHS

LD_RUNPATH_SEARCH_PATHS だけを出力します😇

LD_RUNPATH_SEARCH_PATHS = @executable_path/. @executable_path/PancakeKit.framework/Versions/Current/Frameworks /Library/Frameworks /Library/Frameworks/PancakeKit.framework/Versions/Current/Frameworks

なお変数名の一覧はこちらにあります。
https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html

おまけ

変数名は Xcode の Build Settings の行を選択すると Quick Help に表示されます。
またコピペしたら変数名と設定内容がすぐ取れて意外と便利ですが、ここで確認される方はそもそもコマンドを実行する必要はなさそうですね💦

  • コピー
    RunpathSearchPaths.png

  • ペースト

//:configuration = Debug
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks @loader_path/../Frameworks

//:configuration = Release
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks @loader_path/../Frameworks

//:completeSettings = some
LD_RUNPATH_SEARCH_PATHS

以上

  1. https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html に説明がありますが内容が異なります。

30
23
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
30
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?