Facebook rewrote its iOS app in 2012 to take advantage of native performance and improve reliability and usability over its previous cross-platform HTML5-based implementation.

In the ten years since the rewrite, the app’s codebase has continually evolved to account for the introduction of new features, work around SDK limitations, and keep pace with changes in the iOS platform, explains Facebook engineer Dustin Shahidepour.

Two years after Facebook’s iOS app rewrite, reliability issues related to its use of Core Data began to emerge. Core Data models are internally variable, Shahidepour says, and that makes them difficult to use in a multithreaded app, Infoq wrote on the subject.

Facebook engineers then implemented ComponentKit, a React-inspired declarative framework for defining user interfaces. ComponentKit uses immutable data, which simplifies code reasoning and provides a 50% performance improvement over the previous implementation. ComponentKit has been extremely successful on Facebook, where it is still the default choice for creating iOS UIs.

In 2015, Facebook’s app saw what Shahidepour describes as an “explosion of features” that had the net effect of degrading startup times to the point where the app could risk being killed by iOS. This leads to efforts to modularize the codebase using dynamic libraries (dylibs) so that some code can be loaded lazily, thus reducing the number of tasks that need to be executed before the main one.

Overall, the evolution of Facebook’s iOS app shows a number of strategies that can be useful for overcoming platform limitations and for adapting to the changing nature of the requirements and of the underlying platform. Don’t miss the original article if you’re interested in the full details.

Tags: , , , , , , , , , , , , , , , , , ,
Editor @ DevStyleR