iOS静态库作为具有自定义构建配置的项目的子项目? [英] iOS Static Library as a Subproject of a Project That Has Custom Build Configurations?

查看:89
本文介绍了iOS静态库作为具有自定义构建配置的项目的子项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在多个Xcode项目之间共享代码。我已经按照Apple关于在项目中创建静态库子项目的说明:

I'm trying to share code between multiple Xcode projects. I've followed Apple's notes on creating a static library subproject within a project:

http://developer.apple.com/library/ios/technotes/iOSStaticLibraries/iOSStaticLibraries.pdf

这很棒!但是,当我使用自己的项目遵循相同的说明时,我发现在我的应用程序中的代码无法找到我在静态库中公开的头文件。

This works great! However, when I follow the same instructions using my own project, I find that the header files I make public in the static library can not be found by code within my app.

这是因为我的项目使用自定义构建配置。我有一个用于Ad Hoc构建,App Store构建等。

This is because my project uses custom build configurations. I have one for Ad Hoc builds, App Store builds, etc.

例如:当我使用名为Ad Hoc的构建配置构建项目时,静态库子项目构建Release配置并将其公共标头复制到名为Release的文件夹中。然后主项目无法构建,抱怨它无法找到我从静态库导入的标头。错误在问题导航器中显示为:词法或预处理器问题

For example: when I build the project using a build config called "Ad Hoc", the static library subproject builds the Release configuration and copies its public headers to a folder called "Release". The main project then fails to build, complaining that it can't find headers that I'm importing from the static library. The errors appear in the Issue Navigator as: Lexical or Preprocessor Issue

所以我的问题是:如何将静态库设置为具有构建的项目的子项目库没有的配置?

So my question is: how do you set up a static library as a subproject of a project that has build configurations that the library doesn't?

推荐答案

我在制作自定义项目模板时遇到了这个问题。

I came across this issue when making my custom project templates.

将$(BUILD_DIR)/ Release $(EFFECTIVE_PLATFORM_NAME)添加到标题搜索路径和用户标题搜索路径中,了解您使用的所有构建配置存档并确保它是设置为递归而不是非递归。这将告诉您的应用程序在构建目录中的Release目录中搜索头文件。

Add "$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)" to the "Header Search Paths" and "User Header Search Paths" for any build configurations you use Archive with and make sure it is set to be "recursive" as opposed to "non-recursive". This will tell your app to search the "Release" directory in your build directory for header files.

问题是,对于Debug构建,所有头文件都被复制到单个文件中派生数据下的目录。但是,当您归档文件时,会将文件复制到以构建配置命名的文件夹中。因此,当您执行Ad Hoc构建时,所有文件都会复制到Ad Hoc文件夹,但您的静态库文件会被复制到Release文件夹中。这些文件夹并排放在一起,除非被告知这样做,否则只会在Ad Hoc文件夹下搜索头文件。

The problem is that for Debug builds ALL header files are copied to a single directory under derived data. But when you archive the files are copied to a folder named after the build configuration. So when you do a "Ad Hoc" build all your files get copied to the "Ad Hoc" folder but your static libraries files get copied to the "Release" folder. These folders sit side by side beside one another and unless told to do so the header files will only be searched for under the "Ad Hoc" folder.

这是GitHub提交我修复问题的项目模板
https:/ /github.com/reidmain/Xcode-5-Project-Templates/commit/e465aa3d5c82118cc0d5af3a7f6f094d86b1ec63

Here is the GitHub commit for my project templates where I fixed the problem https://github.com/reidmain/Xcode-5-Project-Templates/commit/e465aa3d5c82118cc0d5af3a7f6f094d86b1ec63

这篇关于iOS静态库作为具有自定义构建配置的项目的子项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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