Bytedance Terminal Technology — Xu Jiguang
background
The development mode of iOS industry is mostly the multi-warehouse component development model of CocoaPods + Xcode + Git. In order to pursue the ultimate RESEARCH and development experience and improve the research and development efficiency, a lot of optimization has been carried out on this research and development mode. However, the following bottlenecks have been encountered and breakthroughs are urgently needed:
- Pod install takes longer: Most of the compilation and optimization work is done by CocoaPods, which takes longer to execute.
- Long compilation time: although at this stage most projects have been transformed from source code compilation to binary compilation, the compilation time is still about ten minutes, and there is no better optimization method on the basis of existing projects.
- Common problems of super large projects: Xcode Index slow, memory explosion, even jammed, long link time.
How to deal with these problems?
In essence, the cause of these problems lies in the huge scale of the project. Accordingly, we stopped the optimization of each node of the traditional mode, and explored a new research and development mode — dynamic research and development mode ARK with “reducing the project scale” as the starting point.
ARK[1] is a dynamic r&d mode with full link coverage, aiming to reduce the scale of the project on the premise of ensuring the engineering experience. Materials required for offline r&d are provided through baseline construction. At the same time, through the real-time dynamic library transformation technology, local research and development only need to download and compile the development warehouse.
Show Case
Dynamic R&D mode The flow chart of local R&D is as follows. Next, take Douyin products as an example to illustrate how to use ARK for local development.
Demonstration based on bytedance local development tool MBox[2].
The flow chart
- Warehouse to download
In the ARK research and development mode, local research and development no longer pulls the main warehouse code, but replaces it with the ARK warehouse. ARK warehouse contains all configurations corresponding to the main warehouse, and no continuous maintenance is required in the later stage of one-time adaptation access.
Compared to traditional APP repositories, which are usually several gigabytes in size, ARK repositories implement the concept of reduced code size. The repository only applies configuration information and does not contain any component code. ARK warehouse is only 2 MB in size and can be downloaded within 1 s.
Use in MBox is just a few clicks away. First select the product to be developed, then check ark mode, select development branch, and finally click Create to complete the repository download in seconds.
- The development of component
To develop components from CocoaPods, download the component repository to the local directory, change the Podfile corresponding to component A to local reference pod A, and then develop components locally. In the DEVELOPMENT process of MBox and ARK, local development can be carried out by simply selecting the component to be developed and clicking Add.
Dynamic development mode ARK supports Checkout From Commit by parsing podfile. lock, which automatically pulls the corresponding component version to the local host based on the component dependency information, bringing convenience and ensuring compilation success.
- pod install
In traditional development mode, Pod Install must go through four steps: resolving Podfile dependencies, downloading dependencies, creating Pods.xcodeProj projects, and integrating workspace. The dependency resolution and downloading dependencies are particularly time-consuming.
In ARK development mode, there are no components in the Podfile, so the time of dependency resolution and dependency download is almost zero. Secondly, since only the components added in the component development step are needed in the project, the reduction of code size in the creation of Pods project and integration project has a significant effect on improving the integration speed.
Without dependency information, the compile and link phases obviously cannot succeed. The ARK solution uses self-developed Cocoapods-ARK and the supporting tool chain to ensure successful compilation, linking, and running. The principle of this solution will be described in the next series of articles.
- Development component compilation & debugging
Open the project’s XCWorkspace with Xcode as in traditional mode, and you can develop and debug the complete application normally.
Only development components are retained in the project, but there are still variables, functions, header file jump ability; The scale of Index and compilation becomes smaller. There is almost no loading state in Xcode, and large projects can be started in seconds. Compilation speed has been greatly improved. In the whole dynamic development process, components are transformed from static library to dynamic library by tool chain, and the link time is obviously shortened.
- View full source code
By default, only the source code of development components is available in ARK project. It is necessary to view the full source code during development. The dynamic R&D process provides pod Doc asynchronous command to achieve this capability, which can be executed during development. After the command execution is completed, the project can be restarted to view the source code of other components in the project through Document Target.
Pod Doc benefits:
- Supports asynchronous and synchronous execution without affecting local development.
- When executing instructions, skip the dependency analysis link, obtain the dependency information from the server, and download the source code.
- through
xcodegen
Asynchronous Document generation project, greatly reducedpod install
Time. - Only reuse
pod installer
Resource download, cache module. - Supports unified authentication for warehouses, and automatically skips unauthorized component warehouses.
earnings
Experience: Consistent with the traditional mode development process, zero-cost switching dynamic research and development mode.
On tools: Standing on the shoulders of giants, CocoaPods toolchain related optimizations work in ARK as well.
Time: in the traditional r & D mode, although the whole link development time can be controlled within about 20 minutes after various optimizations, such r & D experience is still not friendly. Development can easily be interrupted by other things during this time interval, and a good development experience should be consistent. Combined with the local development experience, we believe that a coherent development experience should control the engineering integration time in minutes, which is successfully achieved by the current development model, which controls the whole link development time in less than 5 minutes.
Success rate: Success rate is always a neglected indicator of R&D efficiency. According to incomplete data statistics, the local full compilation success rate of applications within the group is less than 50%. Half of the students will retry after the first compilation. Obviously, this is a nightmare for new engineers, which means a lot of time will be wasted in this process. ARK implements the Sandbox philosophy from platform baselines to native toolchains, improving compilation success overall.
Write in the last
ARK has been used by multiple services in Bytedance. From the exploration of the initial technical scheme to the actual application, I encountered a lot of technical difficulties, and also had new thoughts on the research and development mode.
Related technical articles will be shared, please look forward to it.
Further reading
[1] ano: github.com/kuperxu/Kwa…
[2] MBox: mp.weixin.qq.com/s/5_IlQPWnC…
Bytedance Client Infrastructure is a global r&d team of big front-end Infrastructure technology (with r&d teams in Beijing, Shanghai, Hangzhou, Shenzhen, Guangzhou, Singapore and Mountain View), responsible for the construction of the whole big front-end Infrastructure of Bytedance. Improve the performance, stability and engineering efficiency of the company’s entire product line; The supported products include but are not limited to Douyin, Toutiao, Watermelon Video, Feishu, Kechedi, etc. We have in-depth research on mobile terminal, Web, Desktop and other terminals.
Volcanic engine application suite MARS is byte to beat terminal technology team in trill, today’s headlines over the past nine years, watermelon video, books, understand car such as emperor App development practice, for mobile research and development, the front-end development, QA, operations, product managers, project managers and operational role, provide one-stop research and development of the overall solution, We will help enterprises upgrade their R&D models and reduce their overall r&d costs.