Xcode如何使用来引用静态库

file not found with <angled> include; use "quotes" instead 这个错误提示不能使用<>大括号来引用静态库而要使用“”来引用静态库

下面讲解下如何 在工程中使用 <>来引用静态库。 在自己添加的.a 静态库中 如何 使用<>来引用头文件

1.先建立一个APPDemo工程 

2.建立一个静态库工程 在新建静态库工程时将 这个静态库工程 添加到APPDemo工程中,这个很简单。

3.这样的静态库能直接用的只不过 引用时 使用的是#import “” 来 引用 静态库的头文件,就能顺利编译了。 但是 我看着 很难受 既然是静态库 就要搞得 牛逼点。最好能用#import<>来引用静态库的头文件 这样才像静态库的样子。

使用步骤如下:在 自己的静态库里面的 -> Build Settings -> Packaging 选项下(不好找的话在 Search Paths 选项上边) 找到 Public Headers Folder Path 默认 为 /usr/local/include 将这个选择 改为 自己 想要的路径 如 include/wifilib  改好后再 Build Phases -> Copy Files 找到 Subpath 选项 将 内容 改为 刚才 修改的名字 如 改为 include/wifilib 

4.这样的话 在 APPDemo工程 里面 应用 静态库 的头文件时  就可以 #import<wifilib/wififind.h>了。

5.添加依赖简单,进入target“MyLib”的“Build Phases”,展开“Target Dependencies”,添加“静态库”。这样就添加了wifilib的依赖,在编译APPDemo时,编译器就会去编译wifilib 了。

下面 详细 讲讲 xcode 的工程 依赖

https://developer.apple.com/library/ios/featuredarticles/XcodeConcepts/Concept-Targets.html

首先附上原文地址:

http://developer.apple.com/library/mac/#featuredarticles/XcodeConcepts/Concept-Targets.html#//apple_ref/doc/uid/TP40009328-CH4-SW1

然后,粘贴原文,怕以后苹果改了文档连接…

第一版,以后还要逐步修改,更加贴切

Xcode Target

Related Articles

A target specifies a product to build and contains the instructions for building the product from a set of files in a project or workspace. A target defines a single product; it organizes the inputs into the build system—the source files and instructions for processing those source files—required to build that product. Projects can contain one or more targets, each of which produces one product.

The instructions for building a product take the form of build settings and build phases, which you can examine and edit in the Xcode project editor. A target inherits the project build settings, but you can override any of the project settings by specifying different settings at the target level. There can be only one active target at a time; the Xcode scheme specifies the active target.

A target and the product it creates can be related to another target. If a target requires the output of another target in order to build, the first target is said to depend upon the second. If both targets are in the same workspace, Xcode can discover the dependency, in which case it builds the products in the required order. Such a relationship is referred to as an implicit dependency. You can also specify explicit target dependencies in your build settings, and you can specify that two targets that Xcode might expect to have an implicit dependency are actually not dependent. For example, you might build both a library and an application that links against that library in the same workspace. Xcode can discover this relationship and automatically build the library first. However, if you actually want to link against a version of the library other than the one built in the workspace, you can create an explicit dependency in your build settings, which overrides this implicit dependency.

翻译一下,为了自己能更懂。

Xcode Target Target指定一个编译的
产品, Target中包含一些指令,这些指令是关于如何调用在一个工程或者工作区的文件集合来编译这个
产品的。一个Target定一个单独的产品;它管理组织在这个编译系统中,需要用来编译这个产品的输入(输入既是源文件和处理这些源文件的指令)。 用来编译这个产品的指令,是以’编译设置’
(build settings)和’编译阶段’
(build phases)这两个形式存在,你在Xcode的工程编辑器中可以查看和编辑这两项。 (ps:也就是你通过修改这两个内容来达到编辑工程指令的目的,你就是用这种方式来修改和输入编译指令的) Target 沿袭工程编译设置内容,但是你可以在Targe层通过指定不同的属性设置来重写任何工程设置。同一时间只能存在一个活动的Target; Xcode Scheme 指定活动的Target。

Target 以及它所制定的产品可以与另一个Target相关联,如果一个Target需要依赖另一个Target的输出才能编译的话,前者既是依赖于后者的。如果两个Target都是在同一个工作区,Xcode可以发现这个依赖关系,进而以一个正确的顺序编译它们。这种关系被定义为:隐含依赖。你也可以在你的编译设置
(build settings)中指定明显的Target依赖,你可以指定在Xcode可能会期望两个target中存在隐含依赖的关系为非依赖关系。例如,你可能编译一个库文件和一个程序文件,程序文件内部链接了这个库文件,那么Xcode会发现这个这个关系并且自动先编译库文件。然而,如果你事实上想要链接的不是此版本的库文件 ,也就是不想链接这个库文件新编译出来的,你可以在你的编译设置(build settings)里创建一个明显的依赖关系,来覆盖这个隐含依赖。

原版原文:

Xcode Target

A target specifies a product to build and contains the instructions for building the product from a set of files in a project or workspace. A target defines a single product; it organizes the inputs into the build system—the source files and instructions for processing those source files—required to build that product. Projects can contain one or more targets, each of which produces one product.

The instructions for building a product take the form of build settings and build phases, which you can examine and edit in the Xcode project editor. A target inherits the project build settings, but you can override any of the project settings by specifying different settings at the target level. There can be only one active target at a time; the Xcode scheme specifies the active target.

A target and the product it creates can be related to another target. If a target requires the output of another target in order to build, the first target is said to depend upon the second. If both targets are in the same workspace, Xcode can discover the dependency, in which case it builds the products in the required order. Such a relationship is referred to as an implicit dependency. You can also specify explicit target dependencies in your build settings, and you can specify that two targets that Xcode might expect to have an implicit dependency are actually not dependent. For example, you might build both a library and an application that links against that library in the same workspace. Xcode can discover this relationship and automatically build the library first. However, if you actually want to link against a version of the library other than the one built in the workspace, you can create an explicit dependency in your build settings, which overrides this implicit dependency.

Related Articles

    原文作者:jeffasd
    原文地址: https://blog.csdn.net/jeffasd/article/details/51043492
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞