如何引用在Xcode中使用不同配置构建的从属项目?

编程入门 行业动态 更新时间:2024-10-28 00:14:13
本文介绍了如何引用在Xcode中使用不同配置构建的从属项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有两个Xcode项目: Super 和 Sub 。 超级具有自定义配置:企业。 Sub 仅具有默认配置: Debug 和 Release 。 超级对 Sub 具有目标依赖关系。当我使用 Enterprise 配置构建 Super 时, Sub 构建其默认配置为:发布。这将产生以下层次结构:

I have two Xcode projects: Super and Sub. Super has a custom configuration: Enterprise. Sub only has the default configurations: Debug and Release. Super has a target dependency on Sub. When I build Super with the Enterprise configuration, Sub builds with its default configuration: Release. This yields the following hierarchy:

Build |-Products |-Enterprise-iphoneos |-Super.app |-Release-iphoneos |-libSub.a |-Sub |-Sub.h

由于 libSub.a 和 Sub / Sub而无法创建Clang .h 通常与 Super.app 位于同一目录中,但由于 Sub 而位于不同的目录中使用 Release 配置而不是 Enterprise 构建的code>。我控制了两个项目,因此我可以轻松地将 Enterprise 配置添加到 Sub ,但是我觉得必须有一个 Xcode构建设置

Clang fails to build because libSub.a and Sub/Sub.h is normally in the same directory as Super.app, but instead is in a different directory because Sub built with the Release configuration instead of Enterprise. I control both projects, so I could easily add an Enterprise configuration to Sub, but I feel like there must be a magical incantation of Xcode Build Settings to make this work.

推荐答案

我已经通过在父项目中使用Xcode配置文件解决了完全相同的问题-通常您的应用程序。

I have solved exactly the same problem by using Xcode Configuration Files in my parent project - typically your application.

这些是我采取的步骤:

  • 通过新建>其他>配置文件在Xcode中创建基本配置文件。

  • Create a Base Configuration file in Xcode via New > Other > Configuration File.

    写您的基本 xcconfig 文件,我的文件看起来像这样:

    Write your base xcconfig file, mine looks a bit like this:

    /// Configure Search Paths HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/include" "$(BUILT_PRODUCTS_DIR)/usr/local/include" LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../Externals/Libraries/GoogleAnalytics" /// Linker flags OTHER_LDFLAGS=-ObjC -all_load

  • 这里要注意的是, $(BUILT_PRODUCTS_DIR)是以下内容的串联:

    $(BUILD_DIR)/$(CONFIGURATION)-$(PLATFORM_NAME)

  • 为自定义配置编写专门的配置。我创建了一个与Release重复的Ad Hoc配置,因此现在的搜索路径如下:

  • Write a specialised configuration for a custom configuration. I created an Ad Hoc configuration which duplicated Release, therefore my search paths now look like this:

    #include "BaseConfig.xcconfig" /// Ad Hoc search paths HEADER_SEARCH_PATHS = "$(BUILD_DIR)/Release-$(PLATFORM_NAME)/include" "$(BUILD_DIR)/Release-$(PLATFORM_NAME)/usr/local/include" LIBRARY_SEARCH_PATHS = "$(BUILD_DIR)/Release-$(PLATFORM_NAME)" "$(SRCROOT)/../Externals/Sources/GoogleAnalytics"

  • 然后在应用程序项目的信息选项卡中选择配置,以将基本配置用于调试和发布,然后是用于自定义配置的特殊版本。

    Then in your application's project's Info tab select your configurations, to use the Base Configuration for Debug and Release, and then the special one for your custom configuration.

    更多推荐

    如何引用在Xcode中使用不同配置构建的从属项目?

    本文发布于:2023-11-08 09:33:55,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1569014.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:项目   Xcode

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!