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

IosSwiftIos Frameworks

Ios Problem Overview


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

[build_path]/unextended-module.modulemap:2:19: error: umbrella header 'bugtest.h' not found
  umbrella header "bugtest.h"
                  ^
<unknown>:0: error: could not build Objective-C module 'bugtest'

Ios Solutions


Solution 1 - Ios

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.

Fix

Solution 2 - Ios

In Xcode 7 Beta, with Swift 2, 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

Solution 3 - Ios

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

Solution 4 - Ios

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

Solution 5 - Ios

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.

Solution 6 - Ios

Definitely you must to set your framework to public:

enter image description here

Solution 7 - Ios

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

Solution 8 - Ios

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!)

Solution 9 - Ios

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.

Solution 10 - Ios

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

Solution 11 - Ios

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

Solution 12 - Ios

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.

Solution 13 - Ios

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

Solution 14 - Ios

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.

Solution 15 - Ios

None of these fixes above were successful, but after much investigation into cocoapods I discovered this issue was caused by a git configuration where symbolic links were not being created in the git filesystem. These symbolic links are needed to let Xcode know where the headers are for the framework.

The fix:

git config --global core.symlinks true

and reset the file system for git git reset --hard HEAD

and then do a clean build.

Solution 16 - Ios

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

Solution 17 - Ios

In my case, I just built the specific framework with it's scheme. And then rebuild the entire project and it resolved the issue

Solution 18 - Ios

make sure "import paths" in Build Settings includes the file you're trying to include...

Solution 19 - Ios

In my case, the problem appears to have been with an incomplete installation of Xcode 13.3 (13E113).

Here's the error that lead me to this:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.4.sdk/System/Library/Frameworks/Accessibility.framework/Modules/module.modulemap:2:19: umbrella header 'Accessibility.h' not found

It turns out that the header file was literally missing from within the SDK (inside the Xcode app bundle). Looking in the Headers directory of that Accessibility.framework bundle.

This is what it should be:

$ ls -l
total 80
-rw-r--r--  7 andrew  staff  12307 Feb 23 06:14 AXAudiograph.h
-rw-r--r--  1 andrew  staff   2013 Feb 23 06:57 AXBrailleMap.h
-rw-r--r--  1 andrew  staff    402 Feb 23 06:57 AXColorUtilities.h
-rw-r--r--  1 andrew  staff   2612 Feb 23 06:57 AXCustomContent.h
-rw-r--r--  1 andrew  staff    395 Feb 17 01:04 AXFoundation.h
-rw-r--r--  1 andrew  staff   2109 Feb 23 06:57 AXHearingUtilities.h
-rw-r--r--  1 andrew  staff    349 Feb 17 01:04 Accessibility.h

But on this Mac, that directory is empty:

$ ls -l
total 0

We aren't yet sure how this happened. But this particular instance of Xcode is installed in CI, and the installation of Xcode is automated.

Solution 20 - Ios

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

update the pod and build the project.

Solution 21 - Ios

In my 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.

Solution 22 - Ios

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

Solution 23 - Ios

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.

Solution 24 - Ios

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTim BodeitView Question on Stackoverflow
Solution 1 - IosarturgrigorView Answer on Stackoverflow
Solution 2 - IosClaude HouleView Answer on Stackoverflow
Solution 3 - IosClaus JørgensenView Answer on Stackoverflow
Solution 4 - IosTim BodeitView Answer on Stackoverflow
Solution 5 - IosAleksei MinaevView Answer on Stackoverflow
Solution 6 - IosBartłomiej SemańczykView Answer on Stackoverflow
Solution 7 - IosxySVermaView Answer on Stackoverflow
Solution 8 - IosDanraView Answer on Stackoverflow
Solution 9 - IosMax MacLeodView Answer on Stackoverflow
Solution 10 - IosJonathan.View Answer on Stackoverflow
Solution 11 - IosAndrei A.View Answer on Stackoverflow
Solution 12 - IosAna FigueiraView Answer on Stackoverflow
Solution 13 - IosretterdesapokView Answer on Stackoverflow
Solution 14 - IosEironeiaView Answer on Stackoverflow
Solution 15 - IosamleszkView Answer on Stackoverflow
Solution 16 - IosMariusView Answer on Stackoverflow
Solution 17 - IosHudi IlfeldView Answer on Stackoverflow
Solution 18 - IosLittle WatchmanView Answer on Stackoverflow
Solution 19 - IosAndrew MView Answer on Stackoverflow
Solution 20 - IosSubhashView Answer on Stackoverflow
Solution 21 - IosphnmnnView Answer on Stackoverflow
Solution 22 - IosGhislain LeblancView Answer on Stackoverflow
Solution 23 - IosRafael BugajewskiView Answer on Stackoverflow
Solution 24 - IosShengBo.CaiView Answer on Stackoverflow