如何引用在Xcode中使用不同配置构建的从属项目? [英] How do I reference a dependent project built with a different configuration in Xcode?

查看:99
本文介绍了如何引用在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.

这些是我采取的步骤:


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

  1. 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中使用不同配置构建的从属项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆