load("@build_bazel_rules_apple//apple:ios.bzl",
"ios_application",
"ios_extension",
"ios_framework",
)
load("@build_bazel_rules_apple//apple:watchos.bzl",
"watchos_application",
"watchos_extension",
)
load("@build_bazel_rules_swift//swift:swift.bzl",
"swift_library",
)
load("//build-system/bazel-utils:plist_fragment.bzl",
"plist_fragment",
)
load(
"//build-input/data:variables.bzl",
"telegram_build_number",
"telegram_version",
"telegram_bundle_id",
"telegram_aps_environment",
"telegram_team_id",
)
config_setting(
name = "debug",
values = {
"compilation_mode": "dbg",
},
)
genrule(
name = "empty",
outs = ["empty.swift"],
cmd = "touch $(OUTS)",
)
swift_library(
name = "_LocalDebugOptions",
srcs = [":empty"],
copts = [
"-Xfrontend",
"-serialize-debugging-options",
],
deps = [
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
"//submodules/AppBundle:AppBundle",
"//submodules/ObjCRuntimeUtils:ObjCRuntimeUtils",
"//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils",
"//submodules/Crc32:Crc32",
"//submodules/MurMurHash32:MurMurHash32",
"//submodules/StringTransliteration:StringTransliteration",
"//submodules/sqlcipher:sqlcipher",
"//submodules/NumberPluralizationForm:NumberPluralizationForm",
"//submodules/EncryptionProvider:EncryptionProvider",
"//submodules/MtProtoKit:MtProtoKit",
],
module_name = "_LocalDebugOptions",
tags = ["no-remote"],
visibility = ["//visibility:public"],
)
debug_deps = select({
":debug": [":_LocalDebugOptions"],
"//conditions:default": [],
})
filegroup(
name = "AppResources",
srcs = glob([
"Telegram-iOS/Resources/**/*",
], exclude = ["Telegram-iOS/Resources/**/.*"]),
)
filegroup(
name = "AppStringResources",
srcs = glob([
"Telegram-iOS/*.lproj/Localizable.strings",
], exclude = ["Telegram-iOS/*.lproj/**/.*"]),
)
filegroup(
name = "WatchAppStringResources",
srcs = glob([
"Telegram-iOS/*.lproj/Localizable.strings",
], exclude = ["Telegram-iOS/*.lproj/**/.*"]),
)
filegroup(
name = "AppIntentVocabularyResources",
srcs = glob([
"Telegram-iOS/*.lproj/AppIntentVocabulary.plist",
], exclude = ["Telegram-iOS/*.lproj/**/.*"]),
)
filegroup(
name = "InfoPlistStringResources",
srcs = glob([
"Telegram-iOS/*.lproj/InfoPlist.strings",
], exclude = ["Telegram-iOS/*.lproj/**/.*"]),
)
filegroup(
name = "Icons",
srcs = glob([
"Telegram-iOS/Icons.xcassets/**/*",
], exclude = ["Telegram-iOS/Icons.xcassets/**/.*"]),
)
filegroup(
name = "AppIcons",
srcs = glob([
"Telegram-iOS/AppIcons.xcassets/**/*",
], exclude = ["Telegram-iOS/AppIcons.xcassets/**/.*"]),
)
filegroup(
name = "DefaultAppIcon",
srcs = glob([
"Telegram-iOS/DefaultAppIcon.xcassets/**/*",
], exclude = ["Telegram-iOS/DefaultAppIcon.xcassets/**/.*"]),
)
filegroup(
name = "AdditionalIcons",
srcs = glob([
"Telegram-iOS/*.png",
]),
)
filegroup(
name = "LaunchScreen",
srcs = glob([
"Telegram-iOS/Base.lproj/LaunchScreen.xib",
]),
)
objc_library(
name = "Main",
srcs = [
"Telegram-iOS/main.m"
],
)
swift_library(
name = "Lib",
srcs = glob([
"Telegram-iOS/Application.swift",
]),
data = [
":AppResources",
":AppIntentVocabularyResources",
":InfoPlistStringResources",
"//submodules/LegacyComponents:LegacyComponentsResources",
"//submodules/OverlayStatusController:OverlayStatusControllerResources",
"//submodules/PasswordSetupUI:PasswordSetupUIResources",
"//submodules/PasswordSetupUI:PasswordSetupUIAssets",
"//submodules/TelegramUI:TelegramUIResources",
"//submodules/TelegramUI:TelegramUIAssets",
],
deps = [
"//submodules/TelegramUI:TelegramUI",
],
)
plist_fragment(
name = "AdditionalInfoPlist",
extension = "plist",
template =
"""
CFBundleShortVersionString
{telegram_version}
CFBundleVersion
{telegram_build_number}
CFBundleURLTypes
CFBundleTypeRole
Viewer
CFBundleURLName
{telegram_bundle_id}
CFBundleURLSchemes
telegram
CFBundleTypeRole
Viewer
CFBundleURLName
{telegram_bundle_id}.ton
CFBundleURLSchemes
ton
CFBundleTypeRole
Viewer
CFBundleURLName
{telegram_bundle_id}.compatibility
CFBundleURLSchemes
tg
""".format(
telegram_version = telegram_version,
telegram_build_number = telegram_build_number,
telegram_bundle_id = telegram_bundle_id,
)
)
official_apple_pay_merchants = [
"merchant.ph.telegra.Telegraph",
"merchant.yandex.ph.telegra.Telegraph",
"merchant.sberbank.ph.telegra.Telegraph",
"merchant.sberbank.test.ph.telegra.Telegraph",
"merchant.privatbank.test.telergramios",
"merchant.privatbank.prod.telergram",
"merchant.telegram.tranzzo.test",
]
official_bundle_ids = [
"ph.telegra.Telegraph",
"org.telegram.Telegram-iOS",
]
apple_pay_merchants = official_apple_pay_merchants if telegram_bundle_id == "ph.telegra.Telegraph" else ""
apple_pay_merchants_fragment = "" if apple_pay_merchants == "" else """
com.apple.developer.in-app-payments
""" + "\n".join([
" {}".format(merchant_id) for merchant_id in apple_pay_merchants
]) + "\n" + """
"""
official_unrestricted_voip_fragment = """
com.apple.developer.pushkit.unrestricted-voip
"""
unrestricted_voip_fragment = official_unrestricted_voip_fragment if telegram_bundle_id in official_bundle_ids else ""
telegram_entitlements_template = """
com.apple.developer.icloud-services
CloudKit
CloudDocuments
com.apple.developer.icloud-container-identifiers
iCloud.{telegram_bundle_id}
aps-environment
{telegram_aps_environment}
com.apple.developer.associated-domains
applinks:telegram.me
applinks:t.me
com.apple.developer.siri
com.apple.security.application-groups
group.{telegram_bundle_id}
application-identifier
{telegram_team_id}.{telegram_bundle_id}
""" + apple_pay_merchants_fragment + unrestricted_voip_fragment
plist_fragment(
name = "TelegramEntitlements",
extension = "entitlements",
template = telegram_entitlements_template.format(
telegram_bundle_id = telegram_bundle_id,
telegram_team_id = telegram_team_id,
telegram_aps_environment = telegram_aps_environment,
)
)
filegroup(
name = "TelegramWatchExtensionResources",
srcs = glob([
"Watch/Extension/Resources/**/*",
], exclude = ["Watch/Extension/Resources/**/.*"]),
)
filegroup(
name = "TelegramWatchAppResources",
srcs = glob([
"Watch/Extension/Resources/**/*.png",
], exclude = ["Watch/Extension/Resources/**/.*"]),
)
filegroup(
name = "TelegramWatchAppAssets",
srcs = glob([
"Watch/App/Assets.xcassets/**/*",
], exclude = ["Watch/App/Assets.xcassets/**/.*"]),
)
filegroup(
name = "TelegramWatchAppInterface",
srcs = glob([
"Watch/App/Base.lproj/Interface.storyboard",
]),
)
objc_library(
name = "TelegramWatchLib",
srcs = glob([
"Watch/Extension/**/*.m",
"Watch/SSignalKit/**/*.m",
"Watch/Bridge/**/*.m",
"Watch/WatchCommonWatch/**/*.m",
"Watch/Extension/**/*.h",
"Watch/SSignalKit/**/*.h",
"Watch/Bridge/**/*.h",
"Watch/WatchCommonWatch/**/*.h",
]),
copts = [
"-DTARGET_OS_WATCH=1",
"-ITelegram/Watch",
"-ITelegram/Watch/Extension",
"-ITelegram/Watch/Bridge",
],
sdk_frameworks = [
"WatchKit",
"WatchConnectivity",
"ClockKit",
"UserNotifications",
"CoreLocation",
"CoreGraphics",
],
)
plist_fragment(
name = "VersionInfoPlist",
extension = "plist",
template =
"""
CFBundleShortVersionString
{telegram_version}
CFBundleVersion
{telegram_build_number}
""".format(
telegram_version = telegram_version,
telegram_build_number = telegram_build_number,
)
)
plist_fragment(
name = "AppNameInfoPlist",
extension = "plist",
template =
"""
CFBundleDisplayName
Telegram
"""
)
plist_fragment(
name = "WatchExtensionNSExtensionInfoPlist",
extension = "plist",
template =
"""
NSExtension
NSExtensionAttributes
WKAppBundleIdentifier
{telegram_bundle_id}.watchkitapp
NSExtensionPointIdentifier
com.apple.watchkit
""".format(
telegram_bundle_id = telegram_bundle_id,
)
)
plist_fragment(
name = "WatchAppCompanionInfoPlist",
extension = "plist",
template =
"""
WKCompanionAppBundleIdentifier
{telegram_bundle_id}
""".format(
telegram_bundle_id = telegram_bundle_id,
)
)
plist_fragment(
name = "WatchExtensionInfoPlist",
extension = "plist",
template =
"""
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
{telegram_bundle_id}.watchkitapp.watchkitextension
CFBundleName
Telegram
CFBundlePackageType
XPC!
WKExtensionDelegateClassName
TGExtensionDelegate
""".format(
telegram_bundle_id = telegram_bundle_id,
)
)
plist_fragment(
name = "WatchAppInfoPlist",
extension = "plist",
template =
"""
CFBundleDevelopmentRegion
en
CFBundleIdentifier
{telegram_bundle_id}.watchkitapp
CFBundleName
Telegram
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
WKWatchKitApp
""".format(
telegram_bundle_id = telegram_bundle_id,
)
)
watchos_extension(
name = "TelegramWatchExtension",
bundle_id = "{telegram_bundle_id}.watchkitapp.watchkitextension".format(
telegram_bundle_id = telegram_bundle_id,
),
bundle_name = "TelegramWatchExtension",
infoplists = [
":WatchExtensionInfoPlist",
":VersionInfoPlist",
":AppNameInfoPlist",
":WatchExtensionNSExtensionInfoPlist",
],
minimum_os_version = "5.0",
provisioning_profile = "//build-input/data/provisioning-profiles:WatchExtension.mobileprovision",
resources = [
":TelegramWatchExtensionResources",
],
strings = [
":WatchAppStringResources",
],
deps = [
":TelegramWatchLib",
],
)
watchos_application(
name = "TelegramWatchApp",
#app_icons = ,
bundle_id = "{telegram_bundle_id}.watchkitapp".format(
telegram_bundle_id = telegram_bundle_id,
),
bundle_name = "TelegramWatch",
extension = ":TelegramWatchExtension",
infoplists = [
":WatchAppInfoPlist",
":VersionInfoPlist",
":AppNameInfoPlist",
":WatchAppCompanionInfoPlist",
],
minimum_os_version = "5.0",
provisioning_profile = "//build-input/data/provisioning-profiles:WatchApp.mobileprovision",
resources = [
":TelegramWatchAppResources",
":TelegramWatchAppAssets",
],
storyboards = [
":TelegramWatchAppInterface",
],
strings = [
],
)
swift_library(
name = "ShareExtensionLib",
module_name = "ShareExtensionLib",
srcs = glob([
"Share/**/*.swift",
]),
deps = [
"//submodules/TelegramUI:TelegramUI"
],
)
plist_fragment(
name = "TelegramUIInfoPlist",
extension = "plist",
template =
"""
CFBundleIdentifier
{telegram_bundle_id}.TelegramUI
CFBundleVersion
{telegram_build_number}
CFBundleDevelopmentRegion
en
CFBundleName
TelegramUI
CFBundleShortVersionString
{telegram_version}
""".format(
telegram_bundle_id = telegram_bundle_id,
telegram_version = telegram_version,
telegram_build_number = telegram_build_number,
)
)
ios_framework(
name = "TelegramUIFramework",
bundle_id = "{telegram_bundle_id}.TelegramUI".format(
telegram_bundle_id = telegram_bundle_id,
),
families = [
"iphone",
"ipad",
],
infoplists = [
":TelegramUIInfoPlist",
],
minimum_os_version = "9.0",
deps = [
"//submodules/TelegramUI:TelegramUI",
] + debug_deps,
)
plist_fragment(
name = "ShareInfoPlist",
extension = "plist",
template =
"""
CFBundleDevelopmentRegion
en
CFBundleIdentifier
{telegram_bundle_id}.Share
CFBundleName
Telegram
CFBundlePackageType
XPC!
NSExtension
NSExtensionAttributes
IntentsSupported
INSendMessageIntent
NSExtensionActivationRule
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.audio" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.data" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.vcard" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.pkpass"
).@count == $extensionItem.attachments.@count
).@count > 0
NSExtensionPointIdentifier
com.apple.share-services
NSExtensionPrincipalClass
ShareRootController
""".format(
telegram_bundle_id = telegram_bundle_id,
)
)
ios_extension(
name = "ShareExtension",
bundle_id = "{telegram_bundle_id}.Share".format(
telegram_bundle_id = telegram_bundle_id,
),
families = [
"iphone",
"ipad",
],
infoplists = [
":ShareInfoPlist",
":VersionInfoPlist",
":AppNameInfoPlist",
],
minimum_os_version = "9.0",
provisioning_profile = "//build-input/data/provisioning-profiles:Share.mobileprovision",
deps = [":ShareExtensionLib"],
frameworks = [
":TelegramUIFramework"
],
)
swift_library(
name = "NotificationServiceExtensionLib",
module_name = "NotificationServiceExtensionLib",
srcs = glob([
"NotificationServiceNext/**/*.swift",
]),
deps = [
],
)
plist_fragment(
name = "NotificationServiceInfoPlist",
extension = "plist",
template =
"""
CFBundleDevelopmentRegion
en
CFBundleIdentifier
{telegram_bundle_id}.NotificationService
CFBundleName
Telegram
CFBundlePackageType
XPC!
NSExtension
NSExtensionPointIdentifier
com.apple.usernotifications.service
NSExtensionPrincipalClass
NotificationService
""".format(
telegram_bundle_id = telegram_bundle_id,
)
)
ios_extension(
name = "NotificationServiceExtension",
bundle_id = "{telegram_bundle_id}.NotificationService".format(
telegram_bundle_id = telegram_bundle_id,
),
families = [
"iphone",
"ipad",
],
infoplists = [
":NotificationServiceInfoPlist",
":VersionInfoPlist",
":AppNameInfoPlist",
],
minimum_os_version = "10.0",
provisioning_profile = "//build-input/data/provisioning-profiles:NotificationService.mobileprovision",
deps = [":NotificationServiceExtensionLib"],
frameworks = [
],
)
plist_fragment(
name = "TelegramInfoPlist",
extension = "plist",
template =
"""
BGTaskSchedulerPermittedIdentifiers
{telegram_bundle_id}.refresh
CFBundleAllowMixedLocalizations
CFBundleDevelopmentRegion
en
CFBundleDisplayName
Telegram
CFBundleIdentifier
{telegram_bundle_id}
CFBundleName
Telegram
ITSAppUsesNonExemptEncryption
LSApplicationQueriesSchemes
instagram
comgooglemaps-x-callback
foursquare
here-location
yandexmaps
yandexnavi
comgooglemaps
youtube
twitter
vk
waze
googlechrome
firefox
touch-http
yandexbrowser-open-url
vimeo
vine
coub
uber
citymapper
lyft
opera-http
firefox-focus
ddgQuickLink
moovit
alook
dgis
microsoft-edge-http
brave
onionhttp
ucbrowser
dolphin
LSRequiresIPhoneOS
NSAppTransportSecurity
NSAllowsArbitraryLoads
NSCameraUsageDescription
We need this so that you can take and share photos and videos.
NSContactsUsageDescription
Telegram stores your contacts heavily encrypted in the cloud to let you connect with your friends across all your devices.
NSFaceIDUsageDescription
You can use Face ID to unlock the app.
NSLocationAlwaysUsageDescription
When you send your location to your friends, Telegram needs access to show them a map. You also need this to send locations from an Apple Watch.
NSLocationWhenInUseUsageDescription
When you send your location to your friends, Telegram needs access to show them a map.
NSMicrophoneUsageDescription
We need this so that you can record and share voice messages and videos with sound.
NSMotionUsageDescription
When you send your location to your friends, Telegram needs access to show them a map.
NSPhotoLibraryAddUsageDescription
We need this so that you can share photos and videos from your photo library.
NSPhotoLibraryUsageDescription
We need this so that you can share photos and videos from your photo library.
NSSiriUsageDescription
You can use Siri to send messages.
NSUserActivityTypes
INSendMessageIntent
RemindAboutChatIntent
UIAppFonts
SFCompactRounded-Semibold.otf
UIBackgroundModes
audio
fetch
location
remote-notification
voip
UIDeviceFamily
1
2
UIFileSharingEnabled
UILaunchStoryboardName
LaunchScreen
UIRequiredDeviceCapabilities
armv7
UIRequiresPersistentWiFi
UIStatusBarStyle
UIStatusBarStyleDefault
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UIViewControllerBasedStatusBarAppearance
UIViewEdgeAntialiasing
UIViewGroupOpacity
UTImportedTypeDeclarations
UTTypeConformsTo
public.data
UTTypeDescription
Telegram iOS Color Theme File
UTTypeIconFiles
BlueIcon@3x.png
UTTypeIdentifier
org.telegram.Telegram-iOS.theme
UTTypeTagSpecification
public.filename-extension
tgios-theme
""".format(
telegram_bundle_id = telegram_bundle_id,
)
)
ios_application(
name = "Telegram",
bundle_id = "{telegram_bundle_id}".format(
telegram_bundle_id = telegram_bundle_id,
),
families = ["iphone", "ipad"],
minimum_os_version = "9.0",
provisioning_profile = "//build-input/data/provisioning-profiles:Telegram.mobileprovision",
entitlements = ":TelegramEntitlements.entitlements",
infoplists = [
":TelegramInfoPlist",
":AdditionalInfoPlist",
],
app_icons = [
":DefaultAppIcon",
],
frameworks = [
":TelegramUIFramework",
],
strings = [
":AppStringResources",
],
extensions = [
#":ShareExtension",
#":NotificationServiceExtension",
],
#watch_application = ":TelegramWatchApp",
deps = [
":Main",
":Lib",
],
)