This file provides guidance to coding agents working with code in this repository.
- Do NOT add comments to code except for special markers like
//TODOLANG(for strings that need localization) or similar task markers - Code should be self-documenting through clear naming
Read the matching document before starting the task.
| Task | Document |
|---|---|
| Creating a new screen or controller | docs/swift/TemplateController/README.md, template in TemplateController.swift |
- Telegram-Mac/ - Thin app target: launch and hook installation (
app/), the concreteAccountContext(account/), hook installers and bridges (packages-integration/), strings (en.lproj/Localizable.strings) - packages/ - Swift Package Manager modules; almost every feature and UI lives here
- packages/TGUIKit/ - UI Library
- TelegramShare/ - Share extension
- submodules/ - Core libraries and telegram-ios shared code (TelegramCore, Postbox, SSignalKit)
- core-xprojects/ - Native framework build projects (OpenH264, FFmpeg, WebRTC, etc.)
- docs/ - Guides and code templates, not part of any target
Only the modules you will touch most. Find anything else with grep -rn "func NameController" packages.
| Module | Use it for |
|---|---|
TGUIKit |
Views, TableView, ViewController, modals, Window |
TelegramContext |
AccountContextProtocol; packages take any AccountContextProtocol |
Localization |
strings(), generated from Telegram-Mac/en.lproj/Localizable.strings by tools/swiftgen.sh |
TelegramTheme |
The theme global, TelegramPresentationTheme, deliverOnPrepareQueue |
ColorPalette, TelegramIconsTheme |
Palette colors and theme.icons |
InAppSettings |
App preferences stored in Postbox, FastSettings |
TelegramUtils |
Telegram helpers shared by many features (formatting, peer status text, bestWindow) |
FoundationUtils, Strings, DateUtils, ObjcUtils |
Pure helpers with no Telegram UI |
TelegramMedia, TelegramMediaUtils, TelegramMediaResources |
Players, media fetching and saving, media resources |
LocalAnimations |
Bundled Lottie animations |
InputDataUI |
InputDataController list and form screens, FeatureNavigationHooks |
GeneralRows |
GeneralRowItem and the common table rows |
AlertsUI |
alert, verifyAlert |
AvatarUI, ShortPeerRow, SelectPeersUI, InputView, InlineStickerLayer |
Avatars, peer rows, peer pickers, text input, inline custom emoji |
ChatModeTypes, ChatHistoryModel, MessageUtils, MessageTextUtils |
Chat and message model shared by several screens |
ChatUI, ChatListUI, SettingsUI, PeerInfoUI |
The big screens: chat, chat list, settings, peer info |
PremiumUI, StarsUI, StoriesUI, CallsUI, GalleryUI, WalletUI, ... |
One *UI package per feature screen |
- Add the screen to the package it belongs to; create a new package only for a standalone multi-file feature, copying
packages/GroupsInCommonUI/Package.swift, then add it to thePackagesgroup and link it to theTelegramtarget - Build screens by following docs/swift/TemplateController
- App-only code (
AccountContext, app singletons) is reached through a<Name>Hooksstruct in the package, installed fromTelegram-Mac/packages-integration/hooks/andapp/main.swift - Other features' screens are opened through
FeatureNavigationHooks, never imported
- Declare only modules whose symbols you actually use; never add dependencies "just in case"
- No screen package may depend on another screen package; existing ones are debt
- Keep feature code out of hubs (
TGUIKit,TelegramTheme,TelegramContext,Localization,TelegramUtils,InAppSettings,GeneralRows,InputDataUI); a hub API change recompiles ~90 packages *Shareproducts are for the share extension only
- Packages enforce runtime exclusivity (the app has it off), so
inoutaccess conflicts can trap after a move BETA/STABLE/ALPHA/APP_STOREare false in packages in Xcode UI builds; onlybuildbox/build-mac.shsets them- App extensions like
Peer.isForumandPeer.displayLettersshadow TelegramCore members; in a package call them through hooks
A beta build starts when beta is pushed to origin.
- Commit all pending work on
beta, including any submodule bumps (submodules/telegram-ioscarries the Rust engine) - Merge the feature branches being shipped into
beta, e.g.git merge origin/sam/new-wallet - Bump the build number: increment
CFBundleVersioninTelegram-Mac/Info.plistandTelegramShare/Info.plist, commit asBump the build number to <N> git push origin beta