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