Facebook’s iOS App Architecture

Dustin Shahidehpour, writing for Facebook’s engineering blog:

Facebook for iOS (FBiOS) is the oldest mobile codebase at Meta. Since the app was rewritten in 2012, it has been worked on by thousands of engineers and shipped to billions of users, and it can support hundreds of engineers iterating on it at a time.

As Eric Vitiello commented on Mastodon regarding this post, if we assume “thousands of engineers” means just 2,000, that means a new engineer has started adding code to Facebook’s iOS app every two days, nonstop, for a decade. It’s closer to one new engineer every day if we count only weekdays. Someone should check if Fred Brooks is rolling over in his grave.

After years of iteration, the Facebook codebase does not resemble a typical iOS codebase:

  • It’s full of C++, Objective-C(++), and Swift.
  • It has dozens of dynamically loaded libraries (dylibs), and so many classes that they can’t be loaded into Xcode at once.
  • There is almost zero raw usage of Apple’s SDK — everything has been wrapped or replaced by an in-house abstraction.
  • The app makes heavy use of code generation, spurred by Buck, our custom build system.
  • Without heavy caching from our build system, engineers would have to spend an entire workday waiting for the app to build.

FBiOS was never intentionally architected this way. The app’s codebase reflects 10 years of evolution, spurred by technical decisions necessary to support the growing number of engineers working on the app, its stability, and, above all, the user experience.

I believe Shahidehpour’s post is an attempt at bragging, but to me it reads like a cry for help.

My thoughts turn to Melvin Conway’s eponymous law: “Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization’s communication structure.” If that’s true regarding Facebook’s system design for their iOS app, it’s a miracle the company ever gets anything done.

Tuesday, 7 February 2023