gpt4 book ai didi

macos - 使用 xcodebuild 分离构建目录

转载 作者:行者123 更新时间:2023-12-03 15:08:35 25 4
gpt4 key购买 nike

xcodebuild 的手册页阅读:

Run xcodebuild from the directory containing your project (i.e. the directory containing the projectname.xcodeproj package).



我想保持我的源目录(这是一个 Subversion 外部)干净且未修改,并将我的目标文件和可执行文件构建到完全位于源目录之外的位置。

有没有办法使用 xcodebuild 从终端构建一个单独的构建目录?就像你可以做的 make工具甚至 msbuild在 Windows 上?

最佳答案

为了实现完全分离,必须更改以下build设置(不仅仅是 CONFIGURATION_BUILD_DIR 就像接受的答案所暗示的那样),否则 Xcode 仍然在其默认构建文件夹下构建它的一些工件。

在我的机器上,Xcode 通常会将所有内容构建到 ./Build./DerivedData当前目录是我的项目之一。

我希望 xcodebuild 在 Build-command-line 下构建所有内容文件夹,所以我使用了 xcodebuild -scheme MyScheme -showBuildSettings | grep Build\/为了找到与所有构建路径相对应的所有build设置,并通过试用结束错误,我发现“生成”build设置足以重定向 xcodebuild 生成的所有构建工件到自定义文件夹。

我最终使用了以下命令:

BUILD_DIR=./Build-command-line
DERIVED_DATA_DIR=$(BUILD_DIR)/DerivedData

xcodebuild -project MyProject.xcodeproj \
-IDEBuildOperationMaxNumberOfConcurrentCompileTasks=`sysctl -n hw.ncpu` \
-scheme MyScheme \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 6S Plus,OS=latest' \
-xcconfig command-line-build.xcconfig \
-derivedDataPath $(DERIVED_DATA_DIR) \
test

在哪里 command-line-build.xcconfig是:
HERE_BUILD=$(SRCROOT)/Build-command-line
HERE_INTERMEDIATES=$(HERE_BUILD)/Intermediates

// Paths
// the following paths are enough to redirect everything to $HERE_BUILD
MODULE_CACHE_DIR = $(HERE_BUILD)/DerivedData/ModuleCache
OBJROOT = $(HERE_INTERMEDIATES)
SHARED_PRECOMPS_DIR = $(HERE_INTERMEDIATES)/PrecompiledHeaders
SYMROOT

注:确保在 xcconfig 中使用绝对路径,否则可能会出现错误: Xcode crashing on startup “parentPath must be nil but it is not .

我写了一篇关于这个解决方案的帖子,有一点背景: xcodebuild: how to really change its build path .

附言当然,此信息可能会更改,但截至 Xcode Version 7.3.1 (7D1014)它非常适合我。

关于macos - 使用 xcodebuild 分离构建目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4969932/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com