在 Xcode 中指定子项目的配置
我有一个 Xcode 项目 (A
) 引用另一个项目 (B
)。默认情况下(据我所知)Xcode 将隐式构建与 A
目标配置相匹配的 B
依赖项的配置(例如,“调试”) )。但是,如果我希望将 A
构建为“调试”,将 B
构建为“发布”,该怎么办?我将如何在 Xcode 中指定它?
I have an Xcode project (A
) referencing another project (B
). By default (as far as I understand it) Xcode will implicitly build the configuration for the B
dependency that matches the configuration of the A
's target (e.g., "Debug"). But what if I want, say, A
to build as "Debug" and the B
to build as "Release"? How would I go about specifying that in Xcode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不知道有什么简单的方法,但是您可以通过直接调用 xcodebuild 来通过“运行脚本”构建阶段的依赖关系来暴力破解它。
我知道这只是一个示例,但如果您的真正目标是子项目是发布(无符号)构建,那么只需将子项目构建到库或框架中并检查将生成的二进制文件添加到您的版本控制系统中。每当我有一个很少更改的系统部分并且我不需要调试符号时,我就会继续将其构建为静态库并将其签入。我经常继续将代码移到其他地方(使用带有 .a 的自述文件,说明代码的位置以及它是如何构建的)。这节省了构建和结账的时间,根据我的经验,这对于大型项目来说是无价的。
I don't know of any easy approach, but you can brute-force it by calling xcodebuild directly for the dependency with a "Run Script" build phase.
I know it was just an example, but if your real goal is that the sub-project be a Release (no symbols) build, then you may have a better experience by just building the sub-project into a library or framework and checking the resulting binary into your version control system. Whenever I have a piece of the system that seldom changes and that I don't want debug symbols for, I go ahead and build it as a static library and check it in. I often go ahead and move the code elsewhere as well (with a README file with the .a that says where the code is and how it was built). This saves time on both build and checkout and is invaluable for large projects in my experience.
这可能会有所帮助:如果找不到项目
A
的配置,Xcode 将构建Release
配置作为后备(或者可能是列表中的第一个配置)。然后,您可以使用以下提示“强制”链接: Xcode 自定义构建配置导致静态库“找不到库/文件”
This might help: if the configuration of the project
A
is not found, Xcode will buildRelease
config as a fallback (or maybe the first config of the list).Then you can "force" the link using this tip: Xcode custom build configuration causes "library/file not found" for static libraries
您可以在项目信息中指定默认的“后备”配置。
更改自:
到:
默认为“调试”。
项目文件的差异:
You can specify the default 'fallback' configuration in the project info.
Change from:
to:
And default will be 'Debug'.
Diffs of project file:
是的,Xcode 天然不支持这一点;当您构建目标时,它会构建自身和所有依赖目标的一种配置。
正如 Rob 提到的,解决方法是使用一个聚合目标类型的依赖目标,其中包含单个运行脚本构建阶段,该阶段只需调用 xcodebuild -configuration Release (或其他)。
Yes, this is not naturally supported by Xcode; when you build a target, it builds one configuration of itself and of all dependent targets.
The workaround, as Rob mentioned, is to have a dependent target that's an Aggregate Target type that comprises a single Run Script build phase, which simply invokes xcodebuild -configuration Release (or whatever).