search

Home  >  Q&A  >  body text

objective-c - 通过cocoapods导入的第三方库import时找不到文件

比如

#import "Masonry.h"

上面这样是可以的,没有问题

#import <Masonry/Masonry.h>

这样就不行了,提示找不到文件

PHP中文网PHP中文网2757 days ago783

reply all(3)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-02 09:29:12

    #import <Masonry/Masonry.h>This form will search for the path in the header path setting of your build setting. Of course, if you do not configure the header search path, the file will not be found.

    Why can #import "Masonry.h" be found?
    The reason is that Xcode will include all header files by default, so #import "Masonry.h" is OK.

    In what circumstances is this form of #import <Masonry/Masonry.h> used?
    If your project has multiple targets, configure the header search path and use the form #import <Masonry/Masonry.h>, otherwise header file conflicts will be very annoying.

    Supplementary (the following pictures will make it easier to understand)
    build settings configuration

    Directory structure

    Header file import

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-02 09:29:12

    Does Masonry have a static library? You quoted it like this

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-02 09:29:12

    There is a bug in Xcode: Even if the header file cannot be found when writing code, it can be built.
    Also, if you use a framework, you can use @import Masonry;

    reply
    0
  • Cancelreply