--- title: 原生扩展 - Manifest 混合工具 brief: 本教程介绍了应用的 manifests 混合是如何工作的 --- # Application manifests 一些平台上需要提供 manifests 片段 (或称存根) 来为扩展提供支持. 可以是部分 `AndroidManifest.xml`, `Info.plist` 或者 `engine_template.html` 从应用基础 manifest 开始, 每个扩展 manifest 存根一个一个的被应用. 基础 manifest 可以是默认的 (位于 `builtins\manifests\\...`), 也可以是由用户自定义的. ## 命名和结构 扩展 manifests 必须被放置在适当的指定位置才能生效. /myextension ext.manifest /manifests /android AndroidManifest.xml /ios Info.plist /osx Info.plist /web engine_template.html ## Android Android 平台提供了 manifest 混合工具 (基于 `ManifestMerger2`), `bob.jar` 中使用此工具混合 Manifest. 关于 Android manifests 的详细信息, 参见 [官方文档](https://developer.android.com/studio/build/manifest-merge) ::: sidenote 如果扩展 manifest 中没有设置应用的 `android:targetSdkVersion` , 下列权限会被自动加入: `WRITE_EXTERNAL_STORAGE`, `READ_PHONE_STATE`, `READ_EXTERNAL_STORAGE`. 详情请见 [此文档](https://developer.android.com/studio/build/manifest-merge#implicit_system_permissions). 我们推荐这么设置: `` ::: ### 示例 基础 manifest ```xml ``` 扩展 manifest: ```xml ``` 混合结果 ```xml ``` ## iOS / macOS 对于 `Info.plist` 我们实现了专用的工具混合列表和字典. 可以在键上指定混合属性 `merge`, `keep` 或 `replace`, 默认是 `merge`. ### 示例 基础 Manifest ```xml NSAppTransportSecurity NSExceptionDomains foobar.net testproperty INT 8 REAL 8.0 BASE64 SEVMTE8gV09STEQ= Array1 Foobar a Array2 Foobar a ``` 扩展 manifest: ```xml NSAppTransportSecurity NSExceptionDomains facebook.com NSIncludesSubdomains NSThirdPartyExceptionRequiresForwardSecrecy INT 42 REAL 16.0 BASE64 Rk9PQkFS Array1 Foobar b Array2 Foobar b ``` 混合结果: ```xml NSAppTransportSecurity NSExceptionDomains foobar.net testproperty facebook.com NSIncludesSubdomains NSThirdPartyExceptionRequiresForwardSecrecy INT 8 REAL 16.0 BASE64 SEVMTE8gV09STEQ= INT 42 Array1 Foobar a b Array2 Foobar a Foobar b ``` ## HTML5 对于 html 模板, 我们给各部分命名, 以便混合时相匹配 (比如 "engine-start"). 标签属性可以是 `merge` 或者 `keep`. `merge` 是默认值. ### 示例 基础 manifest ```html ``` 扩展 manifest ```html ``` 混合结果 ```html ```