Swift Framework: Umbrella header '[…].h' not found

后端 未结 22 2020
盖世英雄少女心
盖世英雄少女心 2020-12-07 11:49

In a custom framework containing both Objective-C and Swift code, the Swift compiler throws the following error:

[build_pat         


        
相关标签:
22条回答
  • 2020-12-07 11:54

    There's 4 different ways this can happen, ignoring bugs in previous versions of Xcode

    • You don't have a umbrella header named $(TARGET_NAME).h in your project
    • You have a umbrella header, but it's not set as public. See arturgrigor's answer
    • DEFINES_MODULE is not set to YES
    • CLANG_ENABLE_MODULES is not set to YES
    0 讨论(0)
  • 2020-12-07 11:54

    For me setting 'Use Header Maps' to 'NO' resolved the issue

    0 讨论(0)
  • 2020-12-07 11:57

    I had the same issue and none of the suggested answers helped in my case so I'm leaving this here in case someone has the same problem.

    I had added a "Run script" in "Build phases" but ended up removing it and that's when I started getting the error.

    My solution ended up having to clean the project, rebuild my framework and then my app project built correctly.

    0 讨论(0)
  • 2020-12-07 11:58

    This will happen, when the Always Search User Paths setting is enabled for the Framework target.

    Setting it to No will resolve that error.

    IMHO this is a bug in the Swift Compiler and I have filed a radar with Apple.
    See rdar://21038443

    0 讨论(0)
  • 2020-12-07 12:01

    Definitely you must to set your framework to public:

    0 讨论(0)
  • 2020-12-07 12:01

    There's some excellent answers here already. @Shadow_x99's was very helpful. However, if I could be allowed to supplement with my own experience.

    An umbrella header is identified automatically in the build process. It is not a specified in the target's build settings or inherited from the project settings.

    So to avoid this error that - as of XCode 7 - is as follows;

    warning: no umbrella header found for target 'MyTarget', module map will not be generated

    two important steps must be taken.

    Firstly, the umbrella header must have the same name as the target. So if your target is a framework named MyTarget, there must be a header named MyTarget.h.

    Secondly, in the build phases for MyTarget - as mentioned in that answer - that header file must be listed in the public section as detailed above.

    0 讨论(0)
提交回复
热议问题