xcode 如何更改目标的输出目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11056547/
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 change output directory for a target
提问by Kuldeep Kapade
I am using a workspace where I have a main app project and then a static library project which is used by the main app. I want static library project to spit out libX.a into the main app project directory, because i want to push this libX.a into my Git repo.
我正在使用一个工作区,其中有一个主应用程序项目,然后是一个由主应用程序使用的静态库项目。我希望静态库项目将 libX.a 吐出到主应用程序项目目录中,因为我想将此 libX.a 推送到我的 Git 存储库中。
The changing of build path settings for static lib project should be pushed to its own git repo so other don't have to deal with this change again and again.
静态库项目的构建路径设置的更改应推送到其自己的 git 存储库,以便其他人不必一次又一次地处理此更改。
I tried changing 'Build Products Path' to "$(SRCROOT)/../SharedData" for mt static lib target but it doesn't have any effect.
我尝试将 mt 静态库目标的“构建产品路径”更改为“$(SRCROOT)/../SharedData”,但没有任何效果。
Thanks!
谢谢!
回答by Jeff Sternberg
Go to File -> Project Settings.
Click the Advanced button under Derived Data Location. Under build location select custom and choose your output directory. This will change the variable $(BUILD_DIR) to whatever you set in that field.
Click done and go to your target settings. Under Build Location you can now specify where the targets are output based on that $(BUILD_DIR) macro.
转到文件 -> 项目设置。
单击派生数据位置下的高级按钮。在构建位置下选择自定义并选择您的输出目录。这会将变量 $(BUILD_DIR) 更改为您在该字段中设置的任何内容。
单击完成并转到您的目标设置。在构建位置下,您现在可以根据 $(BUILD_DIR) 宏指定目标的输出位置。
回答by gp-coder
Updated instructions for Xcode 5 up to 6.3.
将 Xcode 5 的说明更新到 6.3。
- Go to
File
->Project settings
- Click the
Advanced
button - Click
Done
, thenDone
once more.
- 去
File
->Project settings
- 点击
Advanced
按钮 - 单击
Done
,然后Done
再次单击。
And you are done!
你已经完成了!
回答by Bob Murphy
Here's a solution you can check into source control, and which I've verified works with Xcode 6.2.
这是一个您可以检查源代码管理的解决方案,我已经验证它适用于 Xcode 6.2。
- Add a .xcconfig file to your project - see this SO question for details.
- In the .xcconfig file, specify the Xcode standard environment variables PROJECT_TEMP_DIR, CONFIGURATION_BUILD_DIR, and BUILT_PRODUCTS_DIR to point to where you want files to wind up.
- 将 .xcconfig 文件添加到您的项目 -有关详细信息,请参阅此 SO 问题。
- 在 .xcconfig 文件中,指定 Xcode 标准环境变量 PROJECT_TEMP_DIR、CONFIGURATION_BUILD_DIR 和 BUILT_PRODUCTS_DIR 以指向您希望文件结束的位置。
Reading Apple's xcconfig format reference, it would seem that simply overriding OBJROOT and SYMROOT in the .xcconfig file would do the trick - but in my testing on Xcode 6.2, changing them has no effect. You have to change those three specific environment variables listed above.
阅读 Apple 的xcconfig 格式参考,似乎简单地覆盖 .xcconfig 文件中的 OBJROOT 和 SYMROOT 就可以解决问题 - 但在我对 Xcode 6.2 的测试中,更改它们没有任何效果。您必须更改上面列出的三个特定环境变量。
This is what I put in an Xcode 6.2 .xcconfig file so intermediate files and executables go into their "traditional" locations:
这是我放入 Xcode 6.2 .xcconfig 文件的内容,以便中间文件和可执行文件进入它们的“传统”位置:
// Intermediate build files go here
PROJECT_TEMP_DIR = $(SRCROOT)/build/$(PROJECT_NAME).build
// Build-related files for the active build configuration go here
CONFIGURATION_BUILD_DIR = $(SRCROOT)/build/$CONFIGURATION
// The final product executables and other build products go here
BUILT_PRODUCTS_DIR = $(SRCROOT)/build/$CONFIGURATION
Don't forget to add the xcconfig file to a Deployment Target -> Configurations to make it work (Click on the Project, Under Info, in the Deployment Target Section under Configurations
不要忘记将 xcconfig 文件添加到部署目标 -> 配置以使其工作(单击项目,在信息下,在配置下的部署目标部分
回答by Abhishek Mitra
回答by Julius Naeumann
回答by Hardik Thakkar
If you want to change build path of your project you can change using following steps.
如果要更改项目的构建路径,可以使用以下步骤进行更改。
1) Choose Xcode > Preferences, and click Locations.
1) 选择 Xcode > Preferences,然后单击 Locations。
2) Click the Advanced button for the Derived Data setting.
2) 单击派生数据设置的高级按钮。
3) Select a build location from the available options, and click Done.
3) 从可用选项中选择构建位置,然后单击完成。
ex. if you choose 'Custom' from Build Locationoption your build will be generate at '/Users/XYZ/Desktop/Build/Products'Location
前任。如果您从Build Location选项中选择“Custom”,您的构建将在“/Users/XYZ/Desktop/Build/Products”位置生成
回答by DaveSawyer
In Xcode 8.x I set the derivedData directory with a command line option in a .sh file that builds the project. Developers can build into their user directories (default Xcode preference), while the official build creates the build in the traditional area:
在 Xcode 8.x 中,我在构建项目的 .sh 文件中使用命令行选项设置了衍生数据目录。开发人员可以在他们的用户目录中构建(默认的 Xcode 偏好),而官方构建在传统区域创建构建:
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
xcodebuild -workspace 'my project.xcworkspace' -scheme 'my project' -configuration Release -derivedDataPath '$SCRIPT_DIR/build'
xcodebuild -workspace 'my project.xcworkspace' -scheme '我的项目' -configuration Release -derivedDataPath '$SCRIPT_DIR/build'