<tfoot id='OrKqn'></tfoot>
    1. <i id='OrKqn'><tr id='OrKqn'><dt id='OrKqn'><q id='OrKqn'><span id='OrKqn'><b id='OrKqn'><form id='OrKqn'><ins id='OrKqn'></ins><ul id='OrKqn'></ul><sub id='OrKqn'></sub></form><legend id='OrKqn'></legend><bdo id='OrKqn'><pre id='OrKqn'><center id='OrKqn'></center></pre></bdo></b><th id='OrKqn'></th></span></q></dt></tr></i><div id='OrKqn'><tfoot id='OrKqn'></tfoot><dl id='OrKqn'><fieldset id='OrKqn'></fieldset></dl></div>
    2. <legend id='OrKqn'><style id='OrKqn'><dir id='OrKqn'><q id='OrKqn'></q></dir></style></legend>

      <small id='OrKqn'></small><noframes id='OrKqn'>

        <bdo id='OrKqn'></bdo><ul id='OrKqn'></ul>
    3. Xcode 4 和嵌套项目——找不到头文件

      时间:2023-05-19

      <small id='wRV9P'></small><noframes id='wRV9P'>

      <tfoot id='wRV9P'></tfoot>

            <tbody id='wRV9P'></tbody>
          • <bdo id='wRV9P'></bdo><ul id='wRV9P'></ul>
            <i id='wRV9P'><tr id='wRV9P'><dt id='wRV9P'><q id='wRV9P'><span id='wRV9P'><b id='wRV9P'><form id='wRV9P'><ins id='wRV9P'></ins><ul id='wRV9P'></ul><sub id='wRV9P'></sub></form><legend id='wRV9P'></legend><bdo id='wRV9P'><pre id='wRV9P'><center id='wRV9P'></center></pre></bdo></b><th id='wRV9P'></th></span></q></dt></tr></i><div id='wRV9P'><tfoot id='wRV9P'></tfoot><dl id='wRV9P'><fieldset id='wRV9P'></fieldset></dl></div>
          • <legend id='wRV9P'><style id='wRV9P'><dir id='wRV9P'><q id='wRV9P'></q></dir></style></legend>

              • 本文介绍了Xcode 4 和嵌套项目——找不到头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我在使用 Xcode 4 和在 Xcode 3.2 下运行良好的嵌套项目时遇到了无数问题.这是一个我无法解决的非常基本的问题:

                I'm having a myriad of problems with Xcode 4 and nested projects that worked just well under Xcode 3.2. Here's a very basic one I cannot solve:

                我正在构建一个可可框架,它需要另一个我有源代码的可可框架.所以我执行通常的步骤:

                I'm building a cocoa framework that requires another cocoa framework for which I have the source. So I perform the usual steps:

                • 将所需框架的.xcodeproj文件拖入我的主框架项目中
                • 在我的主框架下的 TARGETS > MyFramework > Build Phases > Target Dependencies:添加嵌套项目的目标
                • 确保嵌套框架的头文件是公开的
                • 在 Xcode 设置 > 位置 > 构建位置 我将其设置为 将构建产品放置在派生数据位置(推荐)
                • 两个目标的
                • 构建产品路径 都设置为 ${BUILT_PRODUCTS_DIR} 并告诉我它们位于 DerivedData/Debug(或 Release) 位置
                • 两个目标的架构设置相同
                • Drag the .xcodeproj file of the required framework into my main framework project
                • In my main framework under TARGETS > MyFramework > Build Phases > Target Dependencies: Add the nested project's target
                • Make sure the header files of the nested framework are public
                • In Xcode Settings > Locations > Build Location I have it set to Place build products in derived data location (recommended)
                • Build products path of both targets are set to ${BUILT_PRODUCTS_DIR} and tell me they are at the DerivedData/Debug (or Release) location
                • Architecture settings for both targets are identical

                然后我点击 [CMD] + B 进行构建,它告诉我它没有找到嵌套框架的头文件.当我检查设置时,User Header Search Paths 包含 DerivedData/Debug 的路径,并且里面有嵌套的框架目标和 Versions/中的头文件A/标题.

                Then I hit [CMD] + B to build and it tells me that it doesn't find the header files of the nested framework. When I check the settings, User Header Search Paths contain the path to DerivedData/Debug, and inside there is the nested framework target with the header files in Versions/A/Headers.

                我坐在这里,有人知道我做错了什么吗?

                I'm sitting here, anybody an idea what I'm doing wrong?

                当我将 User header search paths 更改为 ${BUILT_PRODUCTS_DIR}/MyFramework.framework/Headers.但是,这在为 Distribution 构建时不起作用,因为框架然后使用它们的发布设置,最终在不同的子目录中......

                The issue goes away when building for Debug when I change the User header search paths to ${BUILT_PRODUCTS_DIR}/MyFramework.framework/Headers. However this doesn't work when building for Distribution as the frameworks then use their Release settings, which ends up in a different subdirectory...

                我的临时解决方案是还为嵌套项目定义 Distribution 配置.这样就可以找到头文件,链接器就可以链接成功了.

                My temporary solution is to also define a Distribution configuration for the nested projects. This way the headers are found and the linker can link successfully.

                推荐答案

                这是我目前的综合知识:

                Here's my synthesized knowledge so far:

                忘记使用 Xcode 的整个 public 标头内容,它是一个 PITA,在归档您的应用程序时无法正常工作.相反,将所有静态库头文件放在 项目 级别,并告诉您的应用在哪里可以找到它.

                Forget the whole public header thing with Xcode, it's a PITA and doesn't work correctly when archiving your app. Instead, have all static library header files on the project level and tell your app where to find it.

                1. 确保所有目标具有构建配置的相同名称(即向静态库添加AdHoc"和Deployment"配置),从而减轻您的痛苦.

                1. Ease your pain by making sure all targets have the same name for the build configuration (i.e. add an "AdHoc" and "Deployment" configuration to the static libraries).

                在构建设置中,指向 Header Search Paths(如果您使用 #include <file.h>)或 User Header Search Paths(如果你使用#include "file.h")到静态库项目的目录.如果静态库项目在您的应用目录中,请使用:

                In build settings, point the Header Search Paths (if you use #include <file.h>) or User Header Search Paths (if you use #include "file.h") to the directory of the static library project. If the static library project is inside your app directory, use this:

                "$(PROJECT_DIR)"(递归启用)

                如果您的目录包含 a) 静态库项目和 b) 您的应用程序,那么这应该可以工作:

                If you have a directory which contains a) the static library project and b) your app, then this should work:

                "$(PROJECT_DIR)/.."(递归启用)

                如果子模块包含已编译的库,请将您的 Library Search Paths 设置为:

                If the submodule contains compiled libraries, set your Library Search Paths to:

                "$(TARGET_BUILD_DIR)"

                确保您使用的所有静态库项目都将跳过安装设置为YES.

                Make sure all the static library projects that you use have Skip Install set to YES.

                同样,在任何静态库中没有公共头文件(构建阶段 复制头文件),否则 Xcode 将无法归档应用程序.

                Again, no public header files (Build Phases Copy Headers) in any of the static libraries, otherwise Xcode will not be able to archive an app.

                确保告诉 Xcode 何时构建静态库,如图所示 在 Apple 的这份技术文档中.

                Make sure to tell Xcode when to build the static libraries, as shown in this Tech Doc from Apple.

                <小时>

                旧答案:


                Old Answer:

                我仍然没有找到解决这个静态库问题的真正方法.对我有用的是:

                I still haven't found a real solution to this problem with static libraries. What works for me is:

                • 为静态库创建AdHoc"配置
                • $(BUILT_PRODUCTS_DIR) 添加到应用程序的用户标头搜索路径(选中 recursive)-> 在运行应用程序时使用此选项
                • 在 Xcode 菜单中,选择 Product > Build For > Build For Archiving
                • Create an "AdHoc" Configuration for the static library
                • Add $(BUILT_PRODUCTS_DIR) to User Header Search paths for the application (with recursive checked) -> this is used when running the app
                • In the Xcode menu, select Product > Build For > Build For Archiving

                这行得通,应用程序找到头文件并自行构建,它最终在 DerivedData//Build/Products/AdHoc-iphoneos/作为应用程序包.遵循来自 TestFlightApp.com 的 这些简单说明(死链接)我可以将此应用程序打包成 IPA 并发送出去.简单地从 Xcode 中选择 Archive 应用程序不会再次找到标头,即使它们确实位于 AdHoc-iphoneos 构建目录中.

                This works, the app finds the header files and builds itself, it ends up in DerivedData//Build/Products/AdHoc-iphoneos/ as an App bundle. Following these simple instructions (dead link) from TestFlightApp.com I can pack this App into an IPA and send it around. Simply selecting to Archive the app from Xcode does again not find the headers, even if they truly are in the AdHoc-iphoneos build directory.

                这篇关于Xcode 4 和嵌套项目——找不到头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:iOS - 将框架故事板链接到 ViewController 以在主项目中使用 下一篇:Swift 项目、Xcode 中的导入框架

                相关文章

                  <bdo id='IZhwt'></bdo><ul id='IZhwt'></ul>

                  <tfoot id='IZhwt'></tfoot>
                  <legend id='IZhwt'><style id='IZhwt'><dir id='IZhwt'><q id='IZhwt'></q></dir></style></legend>
                  <i id='IZhwt'><tr id='IZhwt'><dt id='IZhwt'><q id='IZhwt'><span id='IZhwt'><b id='IZhwt'><form id='IZhwt'><ins id='IZhwt'></ins><ul id='IZhwt'></ul><sub id='IZhwt'></sub></form><legend id='IZhwt'></legend><bdo id='IZhwt'><pre id='IZhwt'><center id='IZhwt'></center></pre></bdo></b><th id='IZhwt'></th></span></q></dt></tr></i><div id='IZhwt'><tfoot id='IZhwt'></tfoot><dl id='IZhwt'><fieldset id='IZhwt'></fieldset></dl></div>

                  <small id='IZhwt'></small><noframes id='IZhwt'>