82

What is basically an umbrella header? What is its use? I got a warning as shown below. What does this mean?

<module-includes>:1:1: warning: umbrella header for module 'XCTest' does not include header 'XCTextCase+AsynchronousTesting.h' [-Wincomplete-umbrella]
#import "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework/Headers/XCTest.h"
Sufian
  • 6,405
  • 16
  • 66
  • 120
ruveena
  • 1,248
  • 1
  • 10
  • 19

2 Answers2

79

The umbrella header is the 'master' header file for a framework. Its use is that you can write

#import <UIKit/UIKit.h>

instead of

#import <UIKit/UIViewController.h>
#import <UIKit/UILabel.h>
#import <UIKit/UIButton.h>
#import <UIKit/UIDatePicker.h>

and so on.

For me, <XCTest/XCTestCase+AsynchronousTesting.h> is included in <XCTest/XCTest.h>. Maybe it is not for you? In that case, add the

#import <XCTest/XCTestCase+AsynchronousTesting.h>

manually.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
  • 6
    +1 for the documentation link, -1 for the explanation, which is wrong. UIKit is not an [umbrella framework](https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html#//apple_ref/doc/uid/20002253-97623-BAJJHAJC). – Nikolai Ruhe Jul 06 '15 at 07:20
  • 4
    `UIKit/UIkit.h` is the "master header file" of a standard (not umbrella) framework. – Nikolai Ruhe Jul 06 '15 at 07:27
  • 2
    @NikolaiRuhe XCTest is not an umbrella framework either. Apparently, the compiler calls it an 'umbrella header', while 'master header' would be a better description. – Glorfindel Jul 06 '15 at 07:49
  • 2
    @Glorfindel I don't know what trickery goes on with XCTest and why clang emits the `-Wincomplete-umbrella`. But your explanation of what an umbrella header is does conflict with the documentation. A master header is not the same as an umbrella header. – Nikolai Ruhe Jul 06 '15 at 07:52
  • 3
    To clarify a bit: @Glorfindel's description is correct and is *not* specific to an umbrella framework (which groups a set of frameworks) - *every* framework has an umbrella header (which groups public header includes) and by default has the same name as the framework, and if you need it to have a different name, [customise the modulemap](http://stackoverflow.com/a/32153383/618653) – t0rst Mar 05 '16 at 11:29
13

Umbrella header

umbrella header - iOS framework or library on Objective-C or Swift can have a header file that contains references to all the other headers in that project.

When you create a framework target Xcode will automatically generate <targer_name.h> file. It should has the same name as PRODUCT_NAME

For example <umbrella_name.h> looks like

#import "header_1.h"
#import "header_2.h"

or:

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

//! Project version number for SomeModule.
FOUNDATION_EXPORT double SomeModuleVersionNumber;

//! Project version string for SomeModule.
FOUNDATION_EXPORT const unsigned char SomeModuleVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <SomeModule/PublicHeader.h>

As a result you can use the next syntax

#import <umbrella_name.h>

instead of

#import <header_1.h>
#import <header_2.h>

On practice when you create a Framework on Objective-C[Example] or Swift[Example] this file will be created automatically with <product_name>

Using

1.umbrella header is required by [.modulemap] structure to use module(expose Objective-C headers) for Objective-C or Swift

2.umbrella header can be just used by Objective-C consumer for connivance

3.umbrella header helps to import every Objective-C header into Swift module that is why you can just skip import

Swift sees every header you expose publicly in your umbrella header. The contents of the Objective-C files in that framework are automatically available from any Swift file within that framework target, with no import statements. Use classes and other declarations from your Objective-C code with the same Swift syntax you use for system classes.

Importing Objective-C into Swift within a Framework Target

yoAlex5
  • 29,217
  • 8
  • 193
  • 205