diff --git a/Telegram/BUILD b/Telegram/BUILD
index c5a4f7e67b..38253612bf 100644
--- a/Telegram/BUILD
+++ b/Telegram/BUILD
@@ -26,6 +26,7 @@ load(
"telegram_bundle_id",
"telegram_aps_environment",
"telegram_team_id",
+ "telegram_enable_icloud",
)
config_setting(
@@ -279,7 +280,7 @@ 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
+" {merchant_id}".format(merchant_id=merchant_id) for merchant_id in apple_pay_merchants
]) + "\n" + """
"""
@@ -296,44 +297,62 @@ official_carplay_fragment = """
"""
carplay_fragment = official_carplay_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
-
+icloud_fragment = "" if not telegram_enable_icloud else """
+com.apple.developer.icloud-services
+
+ CloudKit
+ CloudDocuments
+
+com.apple.developer.icloud-container-identifiers
+
+ iCloud.{telegram_bundle_id}
+
+com.apple.developer.icloud-container-environment
+{telegram_icloud_environment}
+""".format(
+ telegram_bundle_id=telegram_bundle_id,
+ telegram_icloud_environment="Production" if telegram_aps_environment == "production" else "Development"
+)
+
+associated_domains_fragment = "" if telegram_bundle_id not in official_bundle_ids else """
+com.apple.developer.associated-domains
+
+ applinks:telegram.me
+ applinks:t.me
+
+"""
+
+siri_fragment = "" if not telegram_enable_siri else """
+com.apple.developer.siri
+
+"""
+
+aps_fragment = "" if telegram_aps_environment == "" else """
+aps-environment
+{telegram_aps_environment}
+""".format(telegram_aps_environment=telegram_aps_environment)
+
+app_groups_fragment = """
com.apple.security.application-groups
group.{telegram_bundle_id}
application-identifier
{telegram_team_id}.{telegram_bundle_id}
- com.apple.developer.icloud-container-environment
- {telegram_icloud_environment}
-""" + apple_pay_merchants_fragment + unrestricted_voip_fragment + carplay_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,
- telegram_icloud_environment = "Production" if telegram_aps_environment == "production" else "Development",
- )
+ template = "".join([
+ app_groups_fragment,
+ siri_fragment,
+ associated_domains_fragment,
+ icloud_fragment,
+ apple_pay_merchants_fragment,
+ unrestricted_voip_fragment,
+ carplay_fragment
+ ])
)
filegroup(
diff --git a/build-system/example-configuration/variables.bzl b/build-system/example-configuration/variables.bzl
index 489bcd5fde..20d17db1fa 100644
--- a/build-system/example-configuration/variables.bzl
+++ b/build-system/example-configuration/variables.bzl
@@ -9,3 +9,4 @@ telegram_is_appstore_build = "true"
telegram_appstore_id = "686449807"
telegram_app_specific_url_scheme = "tg"
telegram_aps_environment = "production"
+telegram_enable_icloud = true