-
Notifications
You must be signed in to change notification settings - Fork 257
将xml文件编译为flex格式的二进制文件
zhenglibao edited this page Mar 22, 2024
·
6 revisions
默认情况下,使用xml编写的界面布局文件会被打包到app中,如果app编译的是debug版本,则每次都会重新解析xml布局文件;如果app编译的是release版本,则默认情况下只有第一次加载界面布局的时候会读取xml文件,随后会将解析好的布局存储到对应的扩展名为flex的文件中,以后再次加载界面布局的时候将直接读取flex缓存文件。为了避免在release版本下读取到旧的界面布局文件,需要每次打包时修改CFBundleShortVersionString,如果该字段发生了变化,系统将自动清除对应的缓存文件。
另外,您也可以在打包的时候自动将xml文件转换为flex格式的二进制文件,加快界面布局的读取速度。
仓库中的 Doc/res/FlexCompiler 为编译工具,可以将xml编译为flex格式的二进制文件,用法如下 FlexCompiler '源文件' '目标文件'
可以在对应的Target下添加自定义的Build Rule,如下:
在Output Files下添加如下配置:

Flexbox Introduction & performance (in Chinese)
Tutorial 1: Create View Controller with xml layout
Tutorial 2: Create Table Cell with xml layout
Tutorial 3: Embed xml layout into traditional view hierarchy
Tutorial 4: Use custom view in xml layout
Tutorial 5: Create reusable view using xml layout file