Weex features hot updates that bypass App Store approval. However, Weex itself does not provide relevant tools, we need to implement.
In terms of hot updates themselves, the simplest solution is to download a ZIP package and unpack it to replace the original. However, the disadvantage of this solution is that each time you need to download a complete ZIP package, which takes a long time and wastes user traffic. We expect to update only the ones that change at a time to minimize the download volume.
Is there a way to automate finding files that change between versions and updating them? It seems to be a very complicated solution, with so many files and remembering which files are available for each version. Can it be done? This is also possible, think about how Git does it.
Are there any other solutions for incremental updates? Let’s think about it a little differently. We package each version into a ZIP file. Incremental updates can now be solved with a tool that implements the following two requirements:
- Compare two ZIP packages A and B, and generate the difference file patch from A to B;
- B can be generated by A + patch;
One such tool is now available: BSDIff. Bsdiff is a tool to compare files at the binary level. It can compare any file. It is open source and the source code is written in C, which can be easily integrated into iOS.
Bsdiff comes in two parts: BSdiff and BSPatch. Bsdiff is used to generate patch and bSPatch is used to restore. The client only needs to integrate bSPatch and then use the server to fetch patch + old version to generate new version. The core principle is that simple.
What is left is that the server provides an interface to tell the client when the new version and patch address are available according to the business needs.
There is a team in China that has made an incremental update to React Native service, Pushy. The client SDK is open source: React-Native pushy. They also use BSDIff to implement incremental updates, as you can see.
I haven’t posted any code in this article, because the principle is very simple and you can understand it when you tell it. The next article will cover the use of local images in WEEx.