Umbrella frameworks add minor refinements to the standard framework structure, such as the ability to encompass other frameworks

The structure of an umbrella framework is similar to that of a standard framework, and applications do not distinguish between umbrella frameworks and standard frameworks when linking to them. However, two factors distinguish umbrella frameworks from other frameworks. The first is the manner in which they include header files. The second is the fact that they encapsulate subframeworks.

Physically, umbrella frameworks have a similar structure to standard frameworks. One significant difference is the addition of a Frameworks directory to contain the subframeworks that make up the umbrella framework.

For most frameworks, you can include header files other than the master header file. You can include any specific header file you want as long as it is available in the framework’s Headers directory. However, if you are including an umbrella framework, you must include the master header file. Umbrella frameworks do not allow you to include the headers of their constituent subframeworks directly. See Restrictions on Subframework Linking for more information.

1. 在Umbrella Framework新建一个testObject类, 分别产生了testObject.htestObject.m文件。
2. 打开Framework配置文件, 在Build PhasesHeaders里的Public目录下, 将testObject.h文件添加进去。
3. Build Framework看是否报错。
4. 在主工程中调用初始化testObject对象, 看编译是否报错。

• 步骤3: 没有编译报错, 但是报出了Lexical or Preprocessor Issue - Umbrella header for module ‘STDemoUI’ does not include header ‘testObject.h’的警告。
• 步骤4: 执行正常。

1. Standard Framework不能包含Sub Framework; Umbrella Framework可以包含子Framework;

### 规范的写法

1. 在工程全局搜索umbrella关键字 - Failed
2. 在Build Settings里搜索umbrella关键字 - Failed
3. 在打包好的STDemoUI.framework中搜索umbrella关键字 - Bingo

• _CodeSignature: 保存签名相关文件
• Info.plist: 描述了该framework所包含的项目配置信息
• STDemo: 编译后的核心库文件
• Modules: 模块相关文件夹, 目测只包含了module.modulemap文件

#### 指定Modulemap文件

2. 创建一个新的modulemap文件; ex: stdemoalt.modulemap
3. 在新的modulemap中指定umbrella header

1. 在framework的Build Settings中的Module Map File指定新建的modulemap文件

1. Module是什么?
2. 如果Defines Module指定为NO, 那会发生什么事情呢?

### 题外话

While it is possible to create umbrella frameworks using Xcode, doing so is unnecessary for most developers and is not recommended. Apple uses umbrella frameworks to mask some of the interdependencies between libraries in the operating system. In nearly all cases, you should be able to include your code in a single, standard framework bundle. Alternatively, if your code was sufficiently modular, you could create multiple frameworks, but in that case, the dependencies between modules would be minimal or nonexistent and should not warrant the creation of an umbrella for them