gpt4 book ai didi

c++ - XCode3 - 库搜索路径和项目框架之间的关系

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:21:24 26 4
gpt4 key购买 nike

作为来自 VS 的新 MAc 开发人员,我并不真正“了解”什么是框架。如果我向我的项目添加一个框架,这是否自动意味着当我执行 #include <SomeFile.h> 时应该找到 header ? ?

我似乎发现在某些情况下我还必须添加标题搜索路径。这是否意味着框架无法正常工作?

最佳答案

Apple Conceptual Documentation 定义:

A framework is a hierarchical directory that encapsulates shared resources, such as a dynamic shared library, nib files, image files, localized strings, header files, and reference documentation in a single package.

换句话说,它是一个可以被一个或多个应用程序利用的资源的集合,它本身并不是一个应用程序。

详见Apple Conceptual Documentation :

You include framework header files in your code using the #include directive. If you are working in Objective-C, you may use the #import directive instead of the #include directive. The two directives have the same basic results. but the #import directive guarantees that the same header file is never included more than once. There are two ways for including framework headers:

#include <Framework_name/Header_filename.h>
#import <Framework_name/Header_filename.h>

In both cases, Framework_name is the name of the framework and Header_filename is the name of a header file in that framework or in one of its subframeworks.

When including framework header files, it is traditional to include only the master framework header file. The master header file is the header file whose name matches the name of the framework. For example, the Address Book framework has a master header file with the name AddressBook.h.

要包含自定义框架:

If your project links to frameworks that are not included in any of the standard locations, you must explicitly specify the location of that framework before Xcode can locate its header files. To specify the location of such a framework, add the directory containing the framework to the “Framework Search Paths” option of your Xcode project. Xcode passes this list of directories to the compiler and linker, which both use the list to search for the framework resources.

关于c++ - XCode3 - 库搜索路径和项目框架之间的关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10439902/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com