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

天涯浪子 提交于 2019-11-28 15:41:19

This usually happens after a project rename or something like that. The problem is that the umbrella header is no longer listed as a Public header. Check the attached image to see how to fix this.

In XCode 7 Beta, with Swift2, it will also happen if your Framework Header is not declared as "Public"

For instance, I had a Cocoa Touch Framework with a "Project" visibility for the header file, and the error "Umbrella Header ... not found" for all swift files in my project, once I had the header "Public", the error went away

Claus Jørgensen

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

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

For me - access level was public but it also fails on umbrella not found. I did move the "Headers" section of the "Build phases" to the top and it started to work. Script to podfile:

post_install do |installer|
installer.pods_project.targets.each do |target|
    phase_name = 'Headers'
    target.build_phases.each do |phase|
        if (phase.display_name.include? phase_name)
            target.build_phases.unshift(phase).uniq! unless target.build_phases.first == phase
        end
    end
end

Have no clue why it is happening. Tried on dummy projects - not happening. Only on big ones with multiple dependencies. Something with compiling BEFORE copying umbrella headers.

Definitely you must to set your framework to public:

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

One more solution: After renaming a folder, the old location might still be listed in the project file for the .h file, even if you updated the location via Xcode's side-bar. This old location causes the umbrella-header error.

Simple solution: Remove the reference to the .h file, and re-add. (and then remember to make it public again!)

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.

I found that with the New Swift Build System and Parallelize Build turned on the scheme I would get errors like in this question. The solution was to link to frameworks that had been imported in the swift source files. (I think previously the app would build because it just happened that the frameworks were linked to something built previously in the serial build queue).

I wrote a script to go through all the imports in all the targets in a workspace and make sure that their frameworks have been linked to in that target.

https://github.com/Jon889/SwiftImportChecker

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.

If you're using Xcode 7.1 and CocoaPods 0.39, there seems to be a swift compiler change that affects some CocoaPods (Nimble, Quick, etc.) Try some of the solutions specified in the this thread: https://github.com/CocoaPods/CocoaPods/issues/4420 however, if neither of them work, try using Xcode 7.0.1 or 7.2 beta. You can get both of them here: https://developer.apple.com/downloads/.

Edit: In my case, to fix the issue, I also had to downgrade CocoaPods to 0.38.2.

Later edit: It seems not to be related to Xcode 7.1. Just downgrading CocoaPods to 0.38.2 should help:

sudo gem uninstall cocoapods -v 0.39
sudo gem install cocoapods -v 0.38.2

Your header file needs to be in the [Build Phases/Headers/Public] section.

If your header file is already in the [Build Phases/Headers/Public] section, many times doing the fallowing solved my problem:

  1. clean the project
  2. move the header file to the "private" or "project" section
  3. move the header file back to the "public" section
  4. rebuild everything again

Remove these files from project's directory. .xcworkspace pods/ and podfile.lock

update the pod and build the project.

I may case problem was caused by remove headers script in Build Phases

function removeHeaders() {  
    find $BUILD_ROOT/...  -name '*.h' -exec rm -f {} \;  
}  
removeHeaders

Deleting this script fixed the problem.

I fixed it by making the Compilation Mode of the problematic framework build settings to Incremental.

I solved this by renaming my module.modulemap to moduleXYZ.modulemap and changing the modulemap file name in the project settings

Eironeia

In my experience you have to choose on the targets the framework which is giving you the error, not the project target.
Then compile, and after compiling it will be available on the project target.

None of the 9 answers helped me, so I tried to create a new project which I could send to Apple to file a bug. I was surprised that I couldn’t reproduce the issue. I checked the build settings and they were equivalent. Apparently this is some kind of bug.

If nothing else helps, try to create a new project and import at least some Objective C & Swift classes from your current project, compare your framework-related build settings to the default values from the new project, and eventually move all files over to the new project.

I've been working on it for a whole day,but it's worth it.I tried all the ways here, but I didn't solve it. I created a new project, an experiment, and I found out User Header Search Path was setted ${SRCROOT} recursive, and I changed it to ${SRCROOT} non-recursive, changed the bridging header path(e.g. #import "SVProgressHUD.h" -> #import "Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.h"), the error went away.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!