build Telegram Messenger iOS App
最近 Telegram 愈來愈紅,彼得潘的很多朋友,像是溫蒂跟奇妙仙子都跑到 Telegram 聊天了。
Telegram Messenger
Pure instant messaging – simple, fast, secure, and synced across all your devices. Over 100 million active users in…
apps.apple.com
像 Telegram 這麼厲害的 App,到底程式是怎麼寫的呢 ? 真想看看它的 Swift 程式。這個夢想現在就可以實現,因為 Telegram 將它的 iOS App open source,我們連到 GitHub 就能下載它的完整程式。
TelegramMessenger/Telegram-iOS
Install the brew package manager, if you haven't already. Install the packages yasm, cmake: brew install yasm cmake…
github.com
從下圖 Telegram-iOS 的 Tag 記錄,我們看到它的最新版 5.14 完全對應 App Store 目前上架的版本。
接下來就讓我們開始進行下載和 compile Telegram App 的大工程吧。
安裝 brew
compile Telegram App 需要事先安裝一些套件,因此我們得先安裝 macOS 上知名的套件管理工具 brew。
我們可在 Terminal 輸入 brew 測試是否已安裝 brew。
若是顯示錯誤訊息 command not found,請參考以下網頁安裝。
Homebrew
The Missing Package Manager for macOS (or Linux).
brew.sh
安裝 yasm & cmake
brew install yasm cmake
安裝 buck
compile Telegram App 需要透過 buck,因此我們必須先進行安裝 buck 的大工程。為了安裝 buck,請先安裝 java & ant。
brew tap AdoptOpenJDK/openjdkbrew cask install adoptopenjdk8brew install ant
接著再安裝 buck。
brew tap facebook/fb
brew install buck
測試 buck
在 terminal 輸入 buck — help,測試 buck 是否安裝成功。
buck --help
若出現以下錯誤訊息,表示 java 的版本有問題。
You're using Java 9, but Buck requires Java 8.
buck 必須搭配 java 8,彼得潘的 Mac 剛好同時安裝 java 8 & 9,因此彼得再接著安裝 jenv,然後利用 jenv 設定採用 java 8 的版本。
安裝 jenv
brew install jenv
在 ~/.zshrc 裡輸入
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
執行以下指令。
source ~/.zshrc
輸入以下指令加入 java 8。
jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
執行以下指令查詢目前有哪些 java 版本。
jenv versions
結果
* system (set by /Users/shih-yingpan/.jenv/version)1.81.8.0.242openjdk64-1.8.0.242
輸入以下指令,設定採用 openjdk64–1.8.0.242
jenv global openjdk64-1.8.0.242
下載 Telegram Messenger iOS App 的 source code
git clone --recursive https://github.com/TelegramMessenger/Telegram-iOS.git
產生 Telegram_Buck.xcworkspace
用 Xcode 打開 Telegram 專案前,我們必須先產生它的 xcworkspace 檔。這部分同樣有點麻煩,必須經過以下步驟:
- 切換到 Telegram-iOS 資料夾下。
cd Telegram-iOS
- 參考以下連結 klaus01 大大提供的解法設定 Telegram-iOS 下的 Makefile & Config/utils.bzl。
Compile issues of release-5.13 · Issue #219 · TelegramMessenger/Telegram-iOS
You can't perform that action at this time. You signed in with another tab or window. You signed out in another tab or…
github.com
- 輸入以下指令,產生 Telegram_Buck.xcworkspace。
make project
此步驟會等很久,建議先出門吃個牛排補充一下體力。
成功產生 Telegram_Buck.xcworkspace 後,它會自動從 Xcode 打開,我們終於看到 Telegram 程式碼的廬山真面目了,果然很壯觀 !
從模擬器啟動 Telegram Messenger App
點選 Start Messaging,然後輸入自己的手機號碼。
此時 Telegram 將傳 code 到我們 iPhone 上的 Telegram App,請從 iPhone 查看 code 數字後,再從模擬器的 Telegram App 輸入 code,開始享用原汁原味的 Telegram。
Cool,看到和 iPhone 上 Telegram 一模一樣的聊天頁面了 ~
Ten articles before and after
Command and control server in social media (Twitter, Instagram, Youtube + Telegram) – Best Telegram
Telegram Inline Keyboards using Google App Script – Best Telegram
Telegram-Powered Bots. This article is a guest post by Eduardo… – Best Telegram
How does Telegram members count impact the ICO investment returns? – Best Telegram
Telegram: The Next Generation Messaging Platform? – Best Telegram
Telegram, Viber, SendInBlue, HubSpot, Google Recaptcha: What’s New in Startup 3.3? – Best Telegram
CafeSwap Twitter And Telegram Challenge – Best Telegram
Telegram прикрывается GDPRом. Зачем — непонятно. – Best Telegram
DEXTools Telegram and Mail Alerts User Guide. – Best Telegram