How Slack modernized its mobile app and made it full Swift on iOS
Link to the original (post date: 2022/01/15)
Slack has managed to modernize its iOS and Android apps and embrace new design trends. This allows a complete switch to Swift for iOS, among other things.
When Slack's engineers decided to revamp their iOS and Android apps, they had to face the reality of two codebases several years old. Its codebase has grown organically, accumulating significant technical debt over time. After abandoning the idea of a complete rewrite and code reuse across platforms, we decided to do a complete refactoring.
To achieve that result, the team set three different goals. These include stabilizing the codebase to remove technical debt, modularizing apps into discrete components, and modernizing design and tech stack efforts.
Stabilization was the first step. For example, on iOS, we rewrote the rest of the app, which was still written in Objective-C, in Swift. According to Slack engineers, having Swift and Objective-C code coexisting in the same project slows compilation and impacts performance. However, interoperability requirements prevented adoption of new Swift language features.
In addition, we had to rewrite code that directly accessed Core Data to use our own Core Data-based persistence framework. This improves performance and stability. Similarly, all network operations have been rewritten to use the interconnect framework.
In Android, most of the work was aimed at splitting up several monoliths used for network and database access. The latter adopts SQLDelight and migrates all existing SQLite queries. Additionally, the Slack team adopted the repository pattern. This makes it easier to improve performance by supporting smarter caching.
A key element of the stabilization phase was tracking progress using clear metrics associated with each of the goals above. For example, to track the transition from Objective-C to Swift, the team used a script to count the number of remaining Objective-C files. Also, counting deprecated class names and method names helped me figure out the rest of the way to my goal.
As mentioned earlier, modularization aims to carve out many components from two existing monoliths. This effort reduced interdependencies and build times that grew along with the codebase. But a big contributor has been the ability for individual teams to work in a more independent way.
Slack engineers have provided much more background and detail about the project's stabilization phase than can be summarized here. So don't miss the original post for the full picture.