Telegram is one of the most popular messaging apps in the world, in terms of its security and ease of use.

To prove the spirit of security and transparency, Telegram has opened the source code on github so that anyone can see it. This is a great thing that developers get. I was very impressed with the architecture of telegram, the technologies that this application has used. It is completely different from what most developers have learned. If you're just learning about UIKit, it's going to be hard to get started. However, let's try to find out. Maybe, one day our level is on par with Telegram's IT engineers 😜.

This series I refer to Bo'sarticle , a dev with code both ios and android. So if you read English, that's good. This document I write for myself to read, and for someone who also has a desire to explore telegram source code if necessary. The first is to read about it, followed by practice with it. Let's get started.

Source code overview.

Telegram-iOS is made up of more than 200 submodules, with more than 2 million lines of code divided into 5 main groups as follows:

  1. App: Module supports the main features of the application such as utils, UI, network …
  2. voIP: Voice calling was released at the end of March 2017.
  3. Watch: Telegram for the watch.
  4. TON: experimental integration with the new blockchain platform.
  5. 3rd-party: External support libraries for the app.

Here are the statistics by picture:

Telegram-iOS is a mixed-language project. Look at the App section, we have about 70% swift code and 24% Objective-C code. Buck is a tool supported in project construction. But now they have switched to Bazel. For those who are not familiar with these tools, it's .xcodeproj or .xcworkspace – things that you're used to building small and medium-sized projects with Xcode. However, in the long run, it will be more difficult to build with them through editing xml files via Xcode, sometimes you will encounter conflict code this file, it is really harmful.

Buck is a build system built by Facebook engineers. It encourages the use of small modules including code and resources, configured in clearer file config and faster build. With any module, it requires 1 BUCK file, containing config rules in dozens of lines, 1 sources folder and folder containing images, audio resources are not required. Then the buck project statement will automatically spawn Xcode project files for engineers using Xcode, and they will be ignored when pushing up git(.gitignore). You can learn more in Makefile. Here's a sample project that uses BUCK to build IOS applications:



This is a list of 229 modules. 136 modules are no more than 2 source files, with several hundred lines of code.


So we have an overview of this Telegam-iOS source code. We will further analyze Submodules in the next posts.

User Avatar

Code Toàn Bug

Code nhiều bug nhiều!

Leave a Reply

Your email address will not be published. Required fields are marked *