Telegram研究(1):安装环境

参考:
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/


环境

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、进入下载后的源代码,

cd Telegram-iOS

2.2 并创建配置参数

# 创建文件夹
mkdir -p $HOME/telegram-configuration
# 复制example-configuration
cp -R build-system/example-configuration/* $HOME/telegram-configuration/
# 复制/appstore-configuration.json
cp build-system/appstore-configuration.json $HOME/telegram-configuration/development-configuration.json
# 复制fake-codesigning
cp -R build-system/fake-codesigning/* $HOME/telegram-configuration/fake-codesigning
image.png

3、创建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 复制到 ~telegram-configuration/fake-codesigning
2、将 xxx/Telegram-iOS/build-system/appstore-configuration.json 复制到 ~/telegram-configuration/development-configuration.json

image.png

增加参数:
--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版本改为安装版本一致即可或者增加参数--overrideXcodeVersion
但是我本地报
Make: error: unrecognized arguments: --overrideXcodeVersion
--overrideXcodeVersion放在命令的generatProject前面就可以解决

image.png

改完后重新执行创建xcode项目的命令,然后就可以正常的创建项目了

还遇到如下问题:
Could not parse the Xcode version from /Library/Developer/CommandLineTools/../Info.plist

解决方案

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

创建好项目后编译报错


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 "//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的参数

/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

原因是最新代码已经使用了iOS16的内容,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官方最新代码已经解决此问题

问题二、报证书过期,设置了忽略证书不生效

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.`

解决方案
将相关对证书校验相关的脚本内容注释掉即可
1、搜索:provisioning profile ExpirationDate得到ENTITLEMENTS_PROFILE_HAS_EXPIRED
2、搜索:ENTITLEMENTS_PROFILE_HAS_EXPIRED得到调用这个地方,注释掉即可

# 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更新

环境

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

下载项目及配置环境过程查看底部之前说明,配置好后执行如下命令生成项目

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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,445评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,889评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,047评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,760评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,745评论 5 367
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,638评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,011评论 3 398
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,669评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,923评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,655评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,740评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,406评论 4 320
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,995评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,961评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,197评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,023评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,483评论 2 342

推荐阅读更多精彩内容