xcode 如何获取Xcode构建目录?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28921091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get the Xcode build directory?
提问by naz
How do I get the URL or url string to the build directory of a workspace or a project? I don't want to set it myself to know what it is instead I want to know the default set by Xcode.
如何获取工作区或项目的构建目录的 URL 或 url 字符串?我不想自己设置它来知道它是什么,而是想知道 Xcode 设置的默认值。
How to get the directory programmatically?
如何以编程方式获取目录?
回答by Sergio
Select you project in the Xcode. On the right side select "Build Settings". Select desired target and under "Build Locations" you will find paths for debug, release and distribution configurations. These paths are relative to your "Deriver Data" directory. To open that directory in Finder, do the following. Xcode menu: Window->Organizer. When you get "Organizer" window, on the left side select you project and on the right side you will get "Derive Data" path. Clicking on the arrow at the end of the "Derived Data" path you will open that directory in the Finder.
在 Xcode 中选择您的项目。在右侧选择“构建设置”。选择所需的目标,在“构建位置”下,您将找到调试、发布和分发配置的路径。这些路径相对于您的“派生数据”目录。要在 Finder 中打开该目录,请执行以下操作。Xcode 菜单:Window->Organizer。当您获得“组织者”窗口时,在左侧选择您的项目,在右侧您将获得“派生数据”路径。单击“派生数据”路径末尾的箭头,您将在 Finder 中打开该目录。
If you want a build directory path to use in some Pre-actions or Post-actions scripts, then variable name for it can be found in Quick Help Inspector, once you clicked on desired build directory in "Build Locations".
如果您希望在某些 Pre-actions 或 Post-actions 脚本中使用构建目录路径,那么一旦您在“构建位置”中单击所需的构建目录,就可以在 Quick Help Inspector 中找到它的变量名称。
回答by Daniel Jones
If you need the build directory path for use within an Xcode build script (Build Phases > Run Script
), then use the following variable:
如果您需要在 Xcode 构建脚本 ( Build Phases > Run Script
) 中使用构建目录路径,请使用以下变量:
$TARGET_BUILD_DIR
$TARGET_BUILD_DIR
For an exhaustive list of all variables exposed by Xcode in build scripts, follow this answer:
有关 Xcode 在构建脚本中公开的所有变量的详尽列表,请遵循以下答案:
$ xcodebuild -project myProject.xcodeproj -target "myTarget" -showBuildSettings
$ xcodebuild -project myProject.xcodeproj -target "myTarget" -showBuildSettings