Telegram研究(1):安裝環(huán)境

參考:
https://github.com/TelegramMessenger/Telegram-iOS/issues/849
https://github.com/TelegramMessenger/Telegram-iOS/issues/877
https://github.com/TelegramMessenger/Telegram-iOS
https://telegra.ph/tgiostests-01-07
https://www.doudianpu.com/telegram/telegram-ioser-ci-kai-fa-zhi-nan-googlezhong-du-yi-lai-zhe-de-huan-jing-da-jian-yu-dai-ma-bian-yi/


環(huán)境

Intel MacOS 12.1
java version "18.0.1"
Python 3.8.9
Xcode 13.4.1
master最新分支
release-9.0.2


1懂版、clone源代碼

git clone --recursive -j8 https://github.com/TelegramMessenger/Telegram-iOS.git

2.1、進(jìn)入下載后的源代碼材原,

cd Telegram-iOS

2.2 并創(chuàng)建配置參數(shù)

# 創(chuàng)建文件夾
mkdir -p $HOME/telegram-configuration
# 復(fù)制example-configuration
cp -R build-system/example-configuration/* $HOME/telegram-configuration/
# 復(fù)制/appstore-configuration.json
cp build-system/appstore-configuration.json $HOME/telegram-configuration/development-configuration.json
# 復(fù)制fake-codesigning
cp -R build-system/fake-codesigning/* $HOME/telegram-configuration/fake-codesigning
image.png

3讥裤、創(chuàng)建xcode項目

python3 build-system/Make/Make.py \
    --overrideXcodeVersion \
    --cacheDir="$HOME/telegram-bazel-cache" \
    generateProject \
    --configurationPath="$HOME/telegram-configuration/development-configuration.json"  \
    --codesigningInformationPath "$HOME/telegram-configuration/fake-codesigning" \
    --disableExtensions \
    --disableProvisioningProfiles

錯誤:Make generateProject: error: one of the arguments --gitCodesigningRepository --codesigningInformationPath is required

解決方式:
1、將xxx/Telegram-iOS/build-system/fake-codesigning 復(fù)制到 ~telegram-configuration/fake-codesigning
2、將 xxx/Telegram-iOS/build-system/appstore-configuration.json 復(fù)制到 ~/telegram-configuration/development-configuration.json

image.png

增加參數(shù):
--codesigningInformationPath "$HOME/telegram-configuration/fake-codesigning"

報xcode版本不匹配
Required Xcode version is 14.0, but 13.4.1 is reported by 'xcode-select -p'
解決方式:

xxxx/Telegram-iOS/versions.json中的xcode版本改為安裝版本一致即可或者增加參數(shù)--overrideXcodeVersion
但是我本地報
Make: error: unrecognized arguments: --overrideXcodeVersion
--overrideXcodeVersion放在命令的generatProject前面就可以解決

image.png

改完后重新執(zhí)行創(chuàng)建xcode項目的命令奴璃,然后就可以正常的創(chuàng)建項目了

還遇到如下問題:
Could not parse the Xcode version from /Library/Developer/CommandLineTools/../Info.plist

解決方案

sudo xcode-select --reset
sudo xcode-select --switch /Applications/Xcode.app

創(chuàng)建好項目后編譯報錯


Showing Recent Errors Only
/Users/aaa/Documents/workspace/Telegram-source/Telegram-iOS/Telegram/BUILD:1952:16: ProcessEntitlementsFiles Telegram/Telegram_entitlements.entitlements failed: (Exit 1): plisttool failed: error executing command

On target "http://Telegram:Telegram", provisioning profile ExpirationDate ("2022-10-26T17:10:00") is in the past.

Build did NOT complete successfully

/Users/aaa/Documents/workspace/Telegram-source/Telegram-iOS/build-input/gen/project/Telegram.xcodeproj/.tulsi/Scripts/bazel_build.py:590: Bazel build failed with exit code 1. Please check the build log in Report Navigator (?9) for more information.


這是因為使用的證書都過期了,需要增加--disableProvisioningProfiles的參數(shù)

/Users/aaa/Documents/workspace/Telegram-source/Telegram-iOS/submodules/Media/LocalAudioTranscription/Sources/LocalAudioTranscription.swift:57:37: Value of type 'SFSpeechURLRecognitionRequest' has no member 'addsPunctuation'

image.png

原因是最新代碼已經(jīng)使用了iOS16的內(nèi)容城豁,xcode13不支持這個編譯苟穆,暫時方式一:注釋或使用kvo的方式解決


image.png

方式二:升級xcode到最新版本xcode14.0.1

image.png
Showing Recent Errors Only
/Users/aaa/Documents/workspace/Telegram-source/Telegram-iOS/submodules/AsyncDisplayKit/BUILD:9:13: Compiling submodules/AsyncDisplayKit/Source/ASControlNode.mm failed: (Aborted): wrapped_clang_pp failed: error executing command

/Users/aaa/Documents/workspace/Telegram-source/Telegram-iOS/submodules/AsyncDisplayKit/Source/PublicHeaders/AsyncDisplayKit/ASRecursiveUnfairLock.h:70:3: 'OSSpinLock' is deprecated: first deprecated in iOS 10.0 - Use os_unfair_lock() from <os/lock.h> instead

/Users/aaa/Documents/workspace/Telegram-source/Telegram-iOS/submodules/AsyncDisplayKit/Source/PublicHeaders/AsyncDisplayKit/ASThread.h:282:5: 'OSSpinLock' is deprecated: first deprecated in iOS 10.0 - Use os_unfair_lock() from <os/lock.h> instead

/Users/aaa/Documents/workspace/Telegram-source/Telegram-iOS/submodules/AsyncDisplayKit/Source/PublicHeaders/AsyncDisplayKit/ASThread.h:153:21: 'OSSpinLockTry' is deprecated: first deprecated in iOS 10.0 - Use os_unfair_lock_trylock() from <os/lock.h> instead

/Users/aaa/Documents/workspace/Telegram-source/Telegram-iOS/submodules/AsyncDisplayKit/Source/PublicHeaders/AsyncDisplayKit/ASThread.h:178:11: 'OSSpinLockLock' is deprecated: first deprecated in iOS 10.0 - Use os_unfair_lock_lock() from <os/lock.h> instead

/Users/aaa/Documents/workspace/Telegram-source/Telegram-iOS/submodules/AsyncDisplayKit/Source/PublicHeaders/AsyncDisplayKit/ASThread.h:201:11: 'OSSpinLockUnlock' is deprecated: first deprecated in iOS 10.0 - Use os_unfair_lock_unlock() from <os/lock.h> instead

Build did NOT complete successfully

/Users/aaa/Documents/workspace/Telegram-source/Telegram-iOS/build-input/gen/project/Telegram.xcodeproj/.tulsi/Scripts/bazel_build.py:590: Bazel build failed with exit code 1. Please check the build log in Report Navigator (?9) for more information.

#define AS_USE_OS_LOCK false改成#define AS_USE_OS_LOCK true

image.png


運行成功


image.png

問題一、升級MacOS和Xcode后運行Telegram報如下錯誤

error: Could not parse Swift versions from: Swift/ErrorType.swift:200: Fatal error: Error raised at top level: Error Domain=NSCocoaErrorDomain Code=4 "The file “swiftc” doesn’t exist." UserInfo={NSFilePath=swiftc}

解決方案:拉取最新代碼后重新生成唱星,Telegram官方最新代碼已經(jīng)解決此問題

問題二雳旅、報證書過期,設(shè)置了忽略證書不生效

ERROR: /Users/macbookpro/Documents/third/telegram/Telegram-iOS/Telegram/BUILD:1955:16: ProcessEntitlementsFiles Telegram/Telegram_entitlements.entitlements failed: (Exit 1): plisttool failed: error executing command (from target //Telegram:Telegram)
(cd /private/var/tmp/_bazel_macbookpro/c16a409a18375be2510dd63bad28d118/rules_xcodeproj.noindex/build_output_base/execroot/main &&
exec env -
APPLE_SDK_PLATFORM=iPhoneSimulator
APPLE_SDK_VERSION_OVERRIDE=17.0
XCODE_VERSION_OVERRIDE=15.0.1.15A507
bazel-out/darwin-opt-exec-2B5CBBC6-ST-8c945a9593fc/bin/external/build_bazel_rules_apple/tools/plisttool/plisttool bazel-out/applebin_ios-ios_x86_64-dbg-ST-0c73515f5804/bin/Telegram/entitlements/Telegramplisttool-control)

Configuration: 078c4bfe815fe328888eed3a62d860580dd34d0b8b7fffcfa3835ee84d3c101c

Execution platform: @local_config_platform//:host

ERROR: On target "@//Telegram:Telegram", provisioning profile ExpirationDate ("2023-10-27T19:16:43") is in the past.
INFO: Elapsed time: 7.171s, Critical Path: 6.37s
INFO: 204 processes: 165 internal, 39 local.
FAILED: Build did NOT complete successfully
error: The bazel build failed, please check the report navigator, which may have more context about the failure.`

解決方案
將相關(guān)對證書校驗相關(guān)的腳本內(nèi)容注釋掉即可
1间聊、搜索:provisioning profile ExpirationDate得到ENTITLEMENTS_PROFILE_HAS_EXPIRED
2攒盈、搜索:ENTITLEMENTS_PROFILE_HAS_EXPIRED得到調(diào)用這個地方,注釋掉即可

# if expire and expire < datetime.datetime.now():
    #   raise PlistToolError(ENTITLEMENTS_PROFILE_HAS_EXPIRED % (
    #       self.target, expire.isoformat()))
image.png

問題三甸饱、OSSpinLock報錯

/Users/macbookpro/Documents/third/telegram/Telegram-iOS/submodules/AsyncDisplayKit/Source/PublicHeaders/AsyncDisplayKit/ASRecursiveUnfairLock.h:70:3: 'OSSpinLock' is deprecated: first deprecated in iOS 10.0 - Use os_unfair_lock() from <os/lock.h> instead [-Werror,-Wdeprecated-declarations]

解決方案:
#define AS_USE_OS_LOCK false改成#define AS_USE_OS_LOCK true

image.png

成功運行并使用Lookin查看UI

Lookin

2023.11.01更新

環(huán)境

Intel MacOS 14.0 Sonama / M1 MacOS 14.0 Sonama
java version "18.0.1"
Python 3.11.4
Xcode 15.0.1

下載項目及配置環(huán)境過程查看底部之前說明沦童,配置好后執(zhí)行如下命令生成項目

python3 build-system/Make/Make.py \
    --overrideXcodeVersion \
    --cacheDir="$HOME/telegram-bazel-cache" \
    generateProject \
    --configurationPath="$HOME/telegram-configuration/development-configuration.json"  \
    --codesigningInformationPath "$HOME/telegram-configuration/fake-codesigning" \
    --disableExtensions \
    --disableProvisioningProfiles

2024.11.21更新

環(huán)境

M1 MacOS 15.0.1 Sequoia
java 20.0.1 2023-04-18
Python 3.10.8
Swift version 6.0
分支:master

問題一:Showing All Messages Unable to discover 'swiftc' command line tool info: Could not parse Swift versions from:
參考:Swift Command Line not working while Xcode works fine - repl_swift not found

sudo xcode-select -s /Applications/Xcode.app
xcrun swift

問題二:
ERROR: On target "@//Telegram:Telegram", provisioning profile ExpirationDate ("2023-10-27T19:16:43") is in the past.

解決方案
將相關(guān)對證書校驗相關(guān)的腳本內(nèi)容注釋掉即可
1瘩燥、搜索:provisioning profile ExpirationDate得到ENTITLEMENTS_PROFILE_HAS_EXPIRED
2、搜索:ENTITLEMENTS_PROFILE_HAS_EXPIRED得到調(diào)用這個地方侮东,注釋掉即可
/xxx/xxx/Telegram-iOS/build-system/bazel-rules/rules_apple/tools/plisttool/plisttool.py

# if expire and expire < datetime.datetime.now():
    #   raise PlistToolError(/ % (
    #       self.target, expire.isoformat()))
python3 build-system/Make/Make.py \
    --overrideXcodeVersion \
    --cacheDir="$HOME/telegram-bazel-cache" \
    generateProject \
    --configurationPath="$HOME/telegram-configuration/development-configuration.json"  \
    --codesigningInformationPath "$HOME/telegram-configuration/fake-codesigning" \
    --disableExtensions \
    --disableProvisioningProfiles
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末伟姐,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子氏豌,更是在濱河造成了極大的恐慌喉酌,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,817評論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件泵喘,死亡現(xiàn)場離奇詭異泪电,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)纪铺,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,329評論 3 385
  • 文/潘曉璐 我一進(jìn)店門相速,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人鲜锚,你說我怎么就攤上這事突诬。” “怎么了芜繁?”我有些...
    開封第一講書人閱讀 157,354評論 0 348
  • 文/不壞的土叔 我叫張陵旺隙,是天一觀的道長。 經(jīng)常有香客問我骏令,道長蔬捷,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,498評論 1 284
  • 正文 為了忘掉前任榔袋,我火速辦了婚禮周拐,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘摘昌。我一直安慰自己速妖,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 65,600評論 6 386
  • 文/花漫 我一把揭開白布聪黎。 她就那樣靜靜地躺著罕容,像睡著了一般。 火紅的嫁衣襯著肌膚如雪稿饰。 梳的紋絲不亂的頭發(fā)上锦秒,一...
    開封第一講書人閱讀 49,829評論 1 290
  • 那天,我揣著相機(jī)與錄音喉镰,去河邊找鬼旅择。 笑死,一個胖子當(dāng)著我的面吹牛侣姆,可吹牛的內(nèi)容都是我干的生真。 我是一名探鬼主播沉噩,決...
    沈念sama閱讀 38,979評論 3 408
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼柱蟀!你這毒婦竟也來了川蒙?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,722評論 0 266
  • 序言:老撾萬榮一對情侶失蹤长已,失蹤者是張志新(化名)和其女友劉穎畜眨,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體术瓮,經(jīng)...
    沈念sama閱讀 44,189評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡康聂,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,519評論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了胞四。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片恬汁。...
    茶點故事閱讀 38,654評論 1 340
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖撬讽,靈堂內(nèi)的尸體忽然破棺而出蕊连,到底是詐尸還是另有隱情,我是刑警寧澤游昼,帶...
    沈念sama閱讀 34,329評論 4 330
  • 正文 年R本政府宣布,位于F島的核電站尝蠕,受9級特大地震影響烘豌,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜看彼,卻給世界環(huán)境...
    茶點故事閱讀 39,940評論 3 313
  • 文/蒙蒙 一廊佩、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧靖榕,春花似錦标锄、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,762評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至星压,卻和暖如春践剂,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背娜膘。 一陣腳步聲響...
    開封第一講書人閱讀 31,993評論 1 266
  • 我被黑心中介騙來泰國打工逊脯, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人竣贪。 一個月前我還...
    沈念sama閱讀 46,382評論 2 360
  • 正文 我出身青樓军洼,卻偏偏與公主長得像巩螃,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子匕争,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 43,543評論 2 349

推薦閱讀更多精彩內(nèi)容