This commit is contained in:
Peter 2019-09-02 15:39:04 +04:00
parent 681565e7f9
commit 284740a01f
8 changed files with 621 additions and 296 deletions

90
BUCK
View File

@ -75,7 +75,7 @@ apple_resource(
)
apple_asset_catalog(
name = 'Icons',
name = "Icons",
dirs = [
"Telegram-iOS/Icons.xcassets",
],
@ -83,7 +83,7 @@ apple_asset_catalog(
)
apple_asset_catalog(
name = 'AppIcons',
name = "AppIcons",
dirs = [
"Telegram-iOS/AppIcons.xcassets",
],
@ -99,9 +99,9 @@ apple_resource(
)
apple_resource(
name = 'LaunchScreen',
name = "LaunchScreen",
files = [
'Telegram-iOS/Base.lproj/LaunchScreen.xib',
"Telegram-iOS/Base.lproj/LaunchScreen.xib",
],
visibility = ["PUBLIC"],
)
@ -130,7 +130,7 @@ apple_binary(
"//:",
"//...",
],
configs = app_binary_configs("Telegram"),
configs = app_binary_configs(),
swift_version = native.read_config("swift", "version"),
srcs = [
"SupportFiles/Empty.swift",
@ -150,7 +150,7 @@ apple_bundle(
binary = ":AppBinary",
product_name = "Telegram",
info_plist = "Telegram-iOS/Info.plist",
info_plist_substitutions = app_info_plist_substitutions("Telegram"),
info_plist_substitutions = app_info_plist_substitutions(),
deps = [
":ShareExtension",
":WidgetExtension",
@ -169,7 +169,7 @@ apple_binary(
srcs = glob([
"Share/**/*.swift",
]),
configs = share_extension_configs("Share"),
configs = share_extension_configs(),
linker_flags = [
"-e",
"_NSExtensionMain",
@ -192,7 +192,7 @@ apple_bundle(
binary = ":ShareBinary",
extension = "appex",
info_plist = "Share/Info.plist",
info_plist_substitutions = share_extension_info_plist_substitutions("Share"),
info_plist_substitutions = share_extension_info_plist_substitutions(),
deps = [
],
xcode_product_type = "com.apple.product-type.app-extension",
@ -205,7 +205,7 @@ apple_binary(
srcs = glob([
"Widget/**/*.swift",
]),
configs = widget_extension_configs("Widget"),
configs = widget_extension_configs(),
swift_compiler_flags = [
"-application-extension",
],
@ -235,7 +235,7 @@ apple_bundle(
binary = ":WidgetBinary",
extension = "appex",
info_plist = "Widget/Info.plist",
info_plist_substitutions = widget_extension_info_plist_substitutions("Widget"),
info_plist_substitutions = widget_extension_info_plist_substitutions(),
deps = [
],
xcode_product_type = "com.apple.product-type.app-extension",
@ -248,7 +248,7 @@ apple_binary(
srcs = glob([
"NotificationContent/**/*.swift",
]),
configs = notification_content_extension_configs("NotificationContent"),
configs = notification_content_extension_configs(),
swift_compiler_flags = [
"-application-extension",
],
@ -274,8 +274,8 @@ apple_bundle(
name = "NotificationContentExtension",
binary = ":NotificationContentBinary",
extension = "appex",
info_plist = "Widget/Info.plist",
info_plist_substitutions = notification_content_extension_info_plist_substitutions("NotificationContent"),
info_plist = "NotificationContent/Info.plist",
info_plist_substitutions = notification_content_extension_info_plist_substitutions(),
deps = [
],
xcode_product_type = "com.apple.product-type.app-extension",
@ -291,7 +291,7 @@ apple_binary(
headers = glob([
"NotificationService/**/*.h",
]),
configs = notification_service_extension_configs("NotificationService"),
configs = notification_service_extension_configs(),
swift_compiler_flags = [
"-application-extension",
],
@ -317,8 +317,8 @@ apple_bundle(
name = "NotificationServiceExtension",
binary = ":NotificationServiceBinary",
extension = "appex",
info_plist = "Widget/Info.plist",
info_plist_substitutions = notification_service_extension_info_plist_substitutions("NotificationService"),
info_plist = "NotificationService/Info.plist",
info_plist_substitutions = notification_service_extension_info_plist_substitutions(),
deps = [
],
xcode_product_type = "com.apple.product-type.app-extension",
@ -331,7 +331,7 @@ apple_binary(
srcs = glob([
"SiriIntents/**/*.swift",
]),
configs = intents_extension_configs("SiriIntents"),
configs = intents_extension_configs(),
swift_compiler_flags = [
"-application-extension",
],
@ -359,8 +359,8 @@ apple_bundle(
name = "IntentsExtension",
binary = ":IntentsBinary",
extension = "appex",
info_plist = "Widget/Info.plist",
info_plist_substitutions = intents_extension_info_plist_substitutions("SiriIntents"),
info_plist = "SiriIntents/Info.plist",
info_plist_substitutions = intents_extension_info_plist_substitutions(),
deps = [
],
xcode_product_type = "com.apple.product-type.app-extension",
@ -391,7 +391,7 @@ apple_binary(
compiler_flags = [
"-DTARGET_OS_WATCH=1",
],
configs = watch_extension_binary_configs("watchkitapp.watchkitextension"),
configs = watch_extension_binary_configs(),
frameworks = [
"$SDKROOT/System/Library/Frameworks/UserNotifications.framework",
"$SDKROOT/System/Library/Frameworks/CoreLocation.framework",
@ -404,13 +404,50 @@ apple_bundle(
binary = ":WatchAppExtensionBinary",
extension = "appex",
info_plist = "Watch/Extension/Info.plist",
info_plist_substitutions = watch_extension_info_plist_substitutions("watchkitapp.watchkitextension"),
info_plist_substitutions = watch_extension_info_plist_substitutions(),
xcode_product_type = "com.apple.product-type.watchkit2-extension",
)
apple_resource(
name = "WatchAppResources",
dirs = [],
files = glob(["Watch/Extension/Resources/*.png"])
)
apple_asset_catalog(
name = "WatchAppAssets",
dirs = [
"Watch/App/Assets.xcassets",
],
visibility = ["PUBLIC"],
)
apple_resource(
name = "WatchAppInterface",
files = [
"Watch/App/Base.lproj/Interface.storyboard",
],
visibility = ["PUBLIC"],
)
apple_resource(
name = "WatchAppStringResources",
files = [],
variants = glob([
"Telegram-iOS/*.lproj/Localizable.strings",
]),
visibility = ["PUBLIC"],
)
apple_binary(
name = "WatchAppBinary",
configs = watch_binary_configs("watch.app")
configs = watch_binary_configs(),
deps = [
":WatchAppResources",
":WatchAppAssets",
":WatchAppInterface",
":WatchAppStringResources",
],
)
apple_bundle(
@ -421,20 +458,13 @@ apple_bundle(
],
extension = "app",
info_plist = "Watch/App/Info.plist",
info_plist_substitutions = watch_info_plist_substitutions("watchkitapp"),
info_plist_substitutions = watch_info_plist_substitutions(),
xcode_product_type = "com.apple.product-type.application.watchapp2",
deps = [
":WatchAppExtension",
":WatchAppResources",
],
)
apple_resource(
name = "WatchAppResources",
dirs = [],
files = glob(["Watch/Extension/Resources/*.png"])
)
# Package
apple_package(

View File

@ -1,4 +1,4 @@
load("//Config:configs.bzl", "library_configs", "framework_library_configs", "info_plist_substitutions")
load("//Config:configs.bzl", "library_configs", "dynamic_library_configs", "info_plist_substitutions")
def apple_lib(
name,
@ -58,54 +58,29 @@ def apple_lib(
linker_flags = []
resolved_linker_flags = linker_flags + additional_linker_flags + ["-Wl,-install_name,@rpath/lib%s.dylib" % (name)]
if native.read_config("custom", "mode") == "project":
native.apple_library(
name = name + "",
srcs = srcs,
header_namespace = name,
module_name = name,
headers = headers,
exported_headers = exported_headers,
deps = deps,
exported_deps = exported_deps,
extra_xcode_files = extra_xcode_files,
frameworks = frameworks,
visibility = visibility,
swift_version = swift_version,
configs = framework_library_configs(name),
modular = modular,
compiler_flags = compiler_flags,
platform_compiler_flags = platform_compiler_flags,
swift_compiler_flags = swift_compiler_flags,
preferred_linkage = "shared",
link_style = "static",
linker_flags = resolved_linker_flags,
)
else:
native.apple_library(
name = name + "",
srcs = srcs,
header_namespace = name,
module_name = name,
soname = "lib" + name + ".dylib",
headers = headers,
exported_headers = exported_headers,
deps = deps,
exported_deps = exported_deps,
extra_xcode_files = extra_xcode_files,
frameworks = frameworks,
visibility = visibility,
swift_version = swift_version,
configs = framework_library_configs(name),
modular = modular,
compiler_flags = compiler_flags,
platform_compiler_flags = platform_compiler_flags,
swift_compiler_flags = swift_compiler_flags,
preferred_linkage = "shared",
link_style = "static",
linker_flags = resolved_linker_flags,
)
native.apple_library(
name = name + "",
srcs = srcs,
header_namespace = name,
module_name = name,
soname = "lib" + name + ".dylib",
headers = headers,
exported_headers = exported_headers,
deps = deps,
exported_deps = exported_deps,
extra_xcode_files = extra_xcode_files,
frameworks = frameworks,
visibility = visibility,
swift_version = swift_version,
configs = dynamic_library_configs(),
modular = modular,
compiler_flags = compiler_flags,
platform_compiler_flags = platform_compiler_flags,
swift_compiler_flags = swift_compiler_flags,
preferred_linkage = "shared",
link_style = "static",
linker_flags = resolved_linker_flags,
)
else:
additional_linker_flags = additional_linker_flags or []
if has_cpp:
@ -240,24 +215,18 @@ def apple_cxx_lib(
def framework_binary_dependencies(names):
result = []
if native.read_config("custom", "mode") == "project":
for name in names:
result.append(name + "#shared")
else:
for name in names:
result.append(name + "#shared")
for name in names:
result.append(name + "#shared")
return result
def framework_bundle_dependencies(names):
result = []
if native.read_config("custom", "mode") == "project":
for name in names:
#result.append(name + "#shared")
pass
else:
for name in names:
result.append(name + "#shared")
pass
return result
def gen_header_targets(header_paths, prefix, flavor, source_rule, source_path):

View File

@ -37,14 +37,110 @@ SHARED_CONFIGS = {
def optimization_config():
return {
"SWIFT_OPTIMIZATION_LEVEL": native.read_config('custom', 'optimization'),
"SWIFT_OPTIMIZATION_LEVEL": native.read_config("custom", "optimization"),
}
# Adding `-all_load` to our binaries works around https://bugs.swift.org/browse/SR-6004.
ALL_LOAD_LINKER_FLAG = "-all_load"
def bundle_identifier(name):
return "org.telegram.Telegram-iOS.%s" % name
def read_config_nonempty(name):
value = native.read_config("custom", name)
if value == None:
fail("Configuration paramter custom.%s should be defined" % name)
elif len(value) == 0:
fail("Configuration paramter custom.%s should not be empty" % name)
else:
return value
def get_codesign_identity(environment):
if environment == "development":
return read_config_nonempty("developmentCodeSignIdentity")
elif environment == "distribution":
return read_config_nonempty("distributionCodeSignIdentity")
else:
fail("Unknown environment " + environment)
def get_provisioning_profile(environment, type):
if type == "app":
return read_config_nonempty(environment + "ProvisioningProfileApp")
elif type == "share":
return read_config_nonempty(environment + "ProvisioningProfileExtensionShare")
elif type == "widget":
return read_config_nonempty(environment + "ProvisioningProfileExtensionWidget")
elif type == "notification_service":
return read_config_nonempty(environment + "ProvisioningProfileExtensionNotificationService")
elif type == "notification_content":
return read_config_nonempty(environment + "ProvisioningProfileExtensionNotificationContent")
elif type == "intents":
return read_config_nonempty(environment + "ProvisioningProfileExtensionIntents")
elif type == "watch_app":
return read_config_nonempty(environment + "ProvisioningProfileWatchApp")
elif type == "watch_extension":
return read_config_nonempty(environment + "ProvisioningProfileWatchExtension")
else:
fail("Unknown provisioning profile type " + type)
def get_development_team():
return read_config_nonempty("developmentTeam")
def add_item_to_subdict(superdict, key, subkey, item):
subdict = dict(superdict[key])
subdict[subkey] = item
superdict[key] = subdict
valid_configurations = ["Debug", "Profile", "Release"]
def add_provisioning_profile_specifier(configs, type):
for configuration in configs:
if configuration not in valid_configurations:
fail("Unknown configuration " + configuration)
configs = dict(configs)
for configuration in valid_configurations:
if configuration == "Debug":
add_item_to_subdict(configs, configuration, "PROVISIONING_PROFILE_SPECIFIER", get_provisioning_profile(environment="development", type=type))
elif configuration == "Profile":
add_item_to_subdict(configs, configuration, "PROVISIONING_PROFILE_SPECIFIER", get_provisioning_profile(environment="development", type=type))
elif configuration == "Release":
add_item_to_subdict(configs, configuration, "PROVISIONING_PROFILE_SPECIFIER", get_provisioning_profile(environment="distribution", type=type))
return configs
def add_codesign_identity(configs):
for configuration in configs:
if configuration not in valid_configurations:
fail("Unknown configuration " + configuration)
configs = dict(configs)
for configuration in valid_configurations:
if configuration == "Debug":
add_item_to_subdict(configs, configuration, "CODE_SIGN_IDENTITY", get_codesign_identity(environment="development"))
elif configuration == "Profile":
add_item_to_subdict(configs, configuration, "CODE_SIGN_IDENTITY", get_codesign_identity(environment="development"))
elif configuration == "Release":
add_item_to_subdict(configs, configuration, "CODE_SIGN_IDENTITY", get_codesign_identity(environment="distribution"))
return configs
def get_codesign_entitlements(type):
if type == "app":
return read_config_nonempty("entitlementsApp")
elif type == "share":
return read_config_nonempty("entitlementsExtensionShare")
elif type == "widget":
return read_config_nonempty("entitlementsExtensionWidget")
elif type == "notification_service":
return read_config_nonempty("entitlementsExtensionNotificationService")
elif type == "notification_content":
return read_config_nonempty("entitlementsExtensionNotificationContent")
elif type == "intents":
return read_config_nonempty("entitlementsExtensionIntents")
else:
fail("unknown provisioning profile type")
def get_build_number():
return read_config_nonempty("buildNumber")
def bundle_identifier(suffix):
return read_config_nonempty("baseApplicationBundleId") + suffix
def library_configs():
lib_specific_config = {
@ -64,7 +160,7 @@ def library_configs():
}
return configs
def framework_library_configs(name):
def dynamic_library_configs():
lib_specific_config = {
"SWIFT_WHOLE_MODULE_OPTIMIZATION": "NO",
@ -73,7 +169,6 @@ def framework_library_configs(name):
# https://developer.apple.com/library/archive/technotes/tn2215/_index.html
"SKIP_INSTALL": "YES",
"MACH_O_TYPE": "mh_dylib",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(name),
"CODE_SIGNING_ALLOWED": "NO",
}
@ -87,154 +182,163 @@ def framework_library_configs(name):
}
return configs
def app_binary_configs(name):
binary_specific_config = {
def app_binary_configs():
config = {
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES": "YES",
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"PRODUCT_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS",
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"CODE_SIGN_ENTITLEMENTS": "Telegram-iOS/Telegram-iOS-Hockeyapp.entitlements",
"DEVELOPMENT_TEAM": "X834Q8SBVP",
"PROVISIONING_PROFILE_SPECIFIER": "match Development org.telegram.Telegram-iOS",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=""),
"CODE_SIGN_ENTITLEMENTS": get_codesign_entitlements("app"),
"DEVELOPMENT_TEAM": get_development_team(),
"ASSETCATALOG_COMPILER_APPICON_NAME": "AppIcon",
"BUILD_NUMBER": appConfig()["buildNumber"],
"BUILD_NUMBER": get_build_number(),
"APP_NAME": "Telegram",
"PRODUCT_NAME": "Telegram",
}
binary_config = merge_dict(SHARED_CONFIGS, binary_specific_config)
binary_config = merge_dict(binary_config, optimization_config())
binary_config = config_with_updated_linker_flags(binary_config, ALL_LOAD_LINKER_FLAG)
return configs_with_config(binary_config)
config = merge_dict(SHARED_CONFIGS, config)
config = merge_dict(config, optimization_config())
config = config_with_updated_linker_flags(config, ALL_LOAD_LINKER_FLAG)
configs = configs_with_config(config)
configs = add_provisioning_profile_specifier(configs, "app")
configs = add_codesign_identity(configs)
return configs
def share_extension_configs(name):
binary_specific_config = {
def share_extension_configs():
config = {
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES": "NO",
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"PRODUCT_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS." + name,
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"CODE_SIGN_ENTITLEMENTS": "Share/Share-HockeyApp.entitlements",
"DEVELOPMENT_TEAM": "X834Q8SBVP",
"PROVISIONING_PROFILE_SPECIFIER": "match Development org.telegram.Telegram-iOS.Share",
"BUILD_NUMBER": appConfig()["buildNumber"],
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".Share"),
"CODE_SIGN_ENTITLEMENTS": get_codesign_entitlements("share"),
"DEVELOPMENT_TEAM": get_development_team(),
"BUILD_NUMBER": get_build_number(),
"APP_NAME": "Telegram",
"PRODUCT_NAME": "ShareExtension",
}
binary_config = merge_dict(SHARED_CONFIGS, binary_specific_config)
binary_config = merge_dict(binary_config, optimization_config())
binary_config = config_with_updated_linker_flags(binary_config, ALL_LOAD_LINKER_FLAG)
return configs_with_config(binary_config)
config = merge_dict(SHARED_CONFIGS, config)
config = merge_dict(config, optimization_config())
config = config_with_updated_linker_flags(config, ALL_LOAD_LINKER_FLAG)
configs = configs_with_config(config)
configs = add_provisioning_profile_specifier(configs, "share")
configs = add_codesign_identity(configs)
return configs
def widget_extension_configs(name):
binary_specific_config = {
def widget_extension_configs():
config = {
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES": "NO",
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"PRODUCT_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS." + name,
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"CODE_SIGN_ENTITLEMENTS": "Widget/Widget-HockeyApp.entitlements",
"DEVELOPMENT_TEAM": "X834Q8SBVP",
"PROVISIONING_PROFILE_SPECIFIER": "match Development org.telegram.Telegram-iOS.Widget",
"BUILD_NUMBER": appConfig()["buildNumber"],
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".Widget"),
"CODE_SIGN_ENTITLEMENTS": get_codesign_entitlements("widget"),
"DEVELOPMENT_TEAM": get_development_team(),
"BUILD_NUMBER": get_build_number(),
"APP_NAME": "Telegram",
"PRODUCT_NAME": "WidgetExtension",
}
binary_config = merge_dict(SHARED_CONFIGS, binary_specific_config)
binary_config = merge_dict(binary_config, optimization_config())
binary_config = config_with_updated_linker_flags(binary_config, ALL_LOAD_LINKER_FLAG)
return configs_with_config(binary_config)
config = merge_dict(SHARED_CONFIGS, config)
config = merge_dict(config, optimization_config())
config = config_with_updated_linker_flags(config, ALL_LOAD_LINKER_FLAG)
configs = configs_with_config(config)
configs = add_provisioning_profile_specifier(configs, "widget")
configs = add_codesign_identity(configs)
return configs
def notification_content_extension_configs(name):
binary_specific_config = {
def notification_content_extension_configs():
config = {
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES": "NO",
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"PRODUCT_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS." + name,
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"CODE_SIGN_ENTITLEMENTS": "NotificationContent/NotificationContent-HockeyApp.entitlements",
"DEVELOPMENT_TEAM": "X834Q8SBVP",
"PROVISIONING_PROFILE_SPECIFIER": "match Development org.telegram.Telegram-iOS.NotificationContent",
"BUILD_NUMBER": appConfig()["buildNumber"],
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".NotificationContent"),
"CODE_SIGN_ENTITLEMENTS": get_codesign_entitlements("notification_content"),
"DEVELOPMENT_TEAM": get_development_team(),
"BUILD_NUMBER": get_build_number(),
"APP_NAME": "Telegram",
"PRODUCT_NAME": "NotificationContentExtension",
}
binary_config = merge_dict(SHARED_CONFIGS, binary_specific_config)
binary_config = merge_dict(binary_config, optimization_config())
binary_config = config_with_updated_linker_flags(binary_config, ALL_LOAD_LINKER_FLAG)
return configs_with_config(binary_config)
config = merge_dict(SHARED_CONFIGS, config)
config = merge_dict(config, optimization_config())
config = config_with_updated_linker_flags(config, ALL_LOAD_LINKER_FLAG)
configs = configs_with_config(config)
configs = add_provisioning_profile_specifier(configs, "notification_content")
configs = add_codesign_identity(configs)
return configs
def notification_service_extension_configs(name):
binary_specific_config = {
def notification_service_extension_configs():
config = {
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES": "NO",
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"PRODUCT_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS." + name,
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"CODE_SIGN_ENTITLEMENTS": "NotificationService/NotificationService-HockeyApp.entitlements",
"DEVELOPMENT_TEAM": "X834Q8SBVP",
"PROVISIONING_PROFILE_SPECIFIER": "match Development org.telegram.Telegram-iOS.NotificationService",
"BUILD_NUMBER": appConfig()["buildNumber"],
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".NotificationService"),
"CODE_SIGN_ENTITLEMENTS": get_codesign_entitlements("notification_service"),
"DEVELOPMENT_TEAM": get_development_team(),
"BUILD_NUMBER": get_build_number(),
"APP_NAME": "Telegram",
"PRODUCT_NAME": "NotificationServiceExtension",
}
binary_config = merge_dict(SHARED_CONFIGS, binary_specific_config)
binary_config = merge_dict(binary_config, optimization_config())
binary_config = config_with_updated_linker_flags(binary_config, ALL_LOAD_LINKER_FLAG)
return configs_with_config(binary_config)
config = merge_dict(SHARED_CONFIGS, config)
config = merge_dict(config, optimization_config())
config = config_with_updated_linker_flags(config, ALL_LOAD_LINKER_FLAG)
configs = configs_with_config(config)
configs = add_provisioning_profile_specifier(configs, "notification_service")
configs = add_codesign_identity(configs)
return configs
def intents_extension_configs(name):
binary_specific_config = {
def intents_extension_configs():
config = {
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES": "NO",
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"PRODUCT_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS." + name,
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"CODE_SIGN_ENTITLEMENTS": "SiriIntents/SiriIntents-HockeyApp.entitlements",
"DEVELOPMENT_TEAM": "X834Q8SBVP",
"PROVISIONING_PROFILE_SPECIFIER": "match Development org.telegram.Telegram-iOS.SiriIntents",
"BUILD_NUMBER": appConfig()["buildNumber"],
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".SiriIntents"),
"CODE_SIGN_ENTITLEMENTS": get_codesign_entitlements("intents"),
"DEVELOPMENT_TEAM": get_development_team(),
"BUILD_NUMBER": get_build_number(),
"APP_NAME": "Telegram",
"PRODUCT_NAME": "IntentsExtension",
}
binary_config = merge_dict(SHARED_CONFIGS, binary_specific_config)
binary_config = merge_dict(binary_config, optimization_config())
binary_config = config_with_updated_linker_flags(binary_config, ALL_LOAD_LINKER_FLAG)
return configs_with_config(binary_config)
config = merge_dict(SHARED_CONFIGS, config)
config = merge_dict(config, optimization_config())
config = config_with_updated_linker_flags(config, ALL_LOAD_LINKER_FLAG)
configs = configs_with_config(config)
configs = add_provisioning_profile_specifier(configs, "intents")
configs = add_codesign_identity(configs)
return configs
def watch_extension_binary_configs(name):
def watch_extension_binary_configs():
config = {
"SDKROOT": "watchos",
"WATCHOS_DEPLOYMENT_TARGET": "4.0",
"TARGETED_DEVICE_FAMILY": "4",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier("watchkitapp.watchkitextension"),
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"DEVELOPMENT_TEAM": "X834Q8SBVP",
"PROVISIONING_PROFILE_SPECIFIER": "match Development org.telegram.Telegram-iOS.watchkitapp.watchkitextension",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".watchkitapp.watchkitextension"),
"DEVELOPMENT_TEAM": get_development_team(),
"LD_RUNPATH_SEARCH_PATHS": "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks",
"WK_COMPANION_APP_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS",
"WK_APP_BUNDLE_IDENTIFIER": bundle_identifier("watchkitapp"),
"WK_COMPANION_APP_BUNDLE_IDENTIFIER": bundle_identifier(suffix=""),
"WK_APP_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".watchkitapp"),
"APP_NAME": "Telegram",
"APP_BUNDLE_ID": "org.telegram.Telegram-iOS",
"BUILD_NUMBER": appConfig()["buildNumber"],
"APP_BUNDLE_ID": bundle_identifier(suffix=""),
"BUILD_NUMBER": get_build_number(),
"ENABLE_BITCODE": "YES",
}
config = config_with_updated_linker_flags(config, ALL_LOAD_LINKER_FLAG)
return configs_with_config(config)
configs = configs_with_config(config)
configs = add_provisioning_profile_specifier(configs, "watch_extension")
configs = add_codesign_identity(configs)
return configs
def watch_binary_configs(name):
def watch_binary_configs():
config = {
"SDKROOT": "watchos",
"WATCHOS_DEPLOYMENT_TARGET": "4.0",
"TARGETED_DEVICE_FAMILY": "4",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier("watchkitapp"),
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"DEVELOPMENT_TEAM": "X834Q8SBVP",
"PROVISIONING_PROFILE_SPECIFIER": "match Development org.telegram.Telegram-iOS.watchkitapp",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".watchkitapp"),
"DEVELOPMENT_TEAM": get_development_team(),
"LD_RUNPATH_SEARCH_PATHS": "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks",
"WK_COMPANION_APP_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS",
"WK_APP_BUNDLE_IDENTIFIER": bundle_identifier("watchkitapp"),
"WK_COMPANION_APP_BUNDLE_IDENTIFIER": bundle_identifier(suffix=""),
"WK_APP_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".watchkitapp"),
"APP_NAME": "Telegram",
"APP_BUNDLE_ID": "org.telegram.Telegram-iOS",
"BUILD_NUMBER": appConfig()["buildNumber"],
"APP_BUNDLE_ID": bundle_identifier(suffix=""),
"ASSETCATALOG_COMPILER_APPICON_NAME": "AppIcon",
"BUILD_NUMBER": get_build_number(),
"ENABLE_BITCODE": "YES",
}
config = config_with_updated_linker_flags(config, ALL_LOAD_LINKER_FLAG)
return configs_with_config(config)
configs = configs_with_config(config)
configs = add_provisioning_profile_specifier(configs, "watch_app")
configs = add_codesign_identity(configs)
return configs
def info_plist_substitutions(name):
substitutions = {
@ -246,114 +350,105 @@ def info_plist_substitutions(name):
}
return substitutions
def app_info_plist_substitutions(name):
def app_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": name,
"PRODUCT_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS",
"PRODUCT_NAME": name,
"APP_NAME": name,
"EXECUTABLE_NAME": "Telegram",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=""),
"PRODUCT_NAME": "Telegram",
"APP_NAME": "Telegram",
"CURRENT_PROJECT_VERSION": "1",
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"APP_SPECIFIC_URL_SCHEME": appConfig()["appSpecificUrlScheme"],
"BUILD_NUMBER": appConfig()["buildNumber"],
"BUILD_NUMBER": get_build_number(),
}
return substitutions
def share_extension_info_plist_substitutions(name):
def share_extension_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": name,
"PRODUCT_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS.Share",
"PRODUCT_NAME": name,
"EXECUTABLE_NAME": "ShareExtension",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".Share"),
"PRODUCT_NAME": "Share",
"APP_NAME": "Telegram",
"CURRENT_PROJECT_VERSION": "1",
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"APP_SPECIFIC_URL_SCHEME": appConfig()["appSpecificUrlScheme"],
"BUILD_NUMBER": appConfig()["buildNumber"],
"BUILD_NUMBER": get_build_number(),
}
return substitutions
def widget_extension_info_plist_substitutions(name):
def widget_extension_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": name,
"PRODUCT_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS.Widget",
"PRODUCT_NAME": name,
"EXECUTABLE_NAME": "WidgetExtension",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".Widget"),
"PRODUCT_NAME": "Widget",
"APP_NAME": "Telegram",
"CURRENT_PROJECT_VERSION": "1",
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"APP_SPECIFIC_URL_SCHEME": appConfig()["appSpecificUrlScheme"],
"BUILD_NUMBER": appConfig()["buildNumber"],
"BUILD_NUMBER": get_build_number(),
}
return substitutions
def notification_content_extension_info_plist_substitutions(name):
def notification_content_extension_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": name,
"PRODUCT_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS.NotificationContent",
"PRODUCT_NAME": name,
"EXECUTABLE_NAME": "NotificationContentExtension",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".NotificationContent"),
"PRODUCT_NAME": "Telegram",
"APP_NAME": "Telegram",
"CURRENT_PROJECT_VERSION": "1",
"BUILD_NUMBER": get_build_number(),
}
return substitutions
def notification_service_extension_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": "NotificationServiceExtension",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".NotificationService"),
"PRODUCT_NAME": "Telegram",
"APP_NAME": "Telegram",
"CURRENT_PROJECT_VERSION": "1",
"BUILD_NUMBER": get_build_number(),
}
return substitutions
def intents_extension_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": "IntentsExtension",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".SiriIntents"),
"PRODUCT_NAME": "Telegram",
"APP_NAME": "Telegram",
"CURRENT_PROJECT_VERSION": "1",
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"APP_SPECIFIC_URL_SCHEME": appConfig()["appSpecificUrlScheme"],
"BUILD_NUMBER": appConfig()["buildNumber"],
"BUILD_NUMBER": get_build_number(),
"PRODUCT_MODULE_NAME": "SiriIntents",
}
return substitutions
def notification_service_extension_info_plist_substitutions(name):
def watch_extension_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": name,
"PRODUCT_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS.NotificationService",
"PRODUCT_NAME": name,
"EXECUTABLE_NAME": "WatchAppExtension",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".watchkitapp.watchkitextension"),
"APP_NAME": "Telegram",
"APP_BUNDLE_ID": bundle_identifier(suffix=""),
"PRODUCT_NAME": "Telegram",
"CURRENT_PROJECT_VERSION": "1",
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"APP_SPECIFIC_URL_SCHEME": appConfig()["appSpecificUrlScheme"],
"BUILD_NUMBER": appConfig()["buildNumber"],
"BUILD_NUMBER": get_build_number(),
}
return substitutions
def intents_extension_info_plist_substitutions(name):
def watch_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": name,
"PRODUCT_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS.SiriIntents",
"PRODUCT_NAME": name,
"EXECUTABLE_NAME": "WatchApp",
"PRODUCT_BUNDLE_IDENTIFIER":bundle_identifier(suffix=".watchkitapp"),
"APP_NAME": "Telegram",
"APP_BUNDLE_ID": bundle_identifier(suffix=""),
"PRODUCT_NAME": "Telegram",
"CURRENT_PROJECT_VERSION": "1",
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"APP_SPECIFIC_URL_SCHEME": appConfig()["appSpecificUrlScheme"],
"BUILD_NUMBER": appConfig()["buildNumber"],
}
return substitutions
def watch_extension_info_plist_substitutions(name):
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": name,
"PRODUCT_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS.watchkitapp.watchkitextension",
"APP_NAME": "Telegram",
"APP_BUNDLE_ID": "org.telegram.Telegram-iOS",
"PRODUCT_NAME": name,
"CURRENT_PROJECT_VERSION": "1",
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"BUILD_NUMBER": appConfig()["buildNumber"],
}
return substitutions
def watch_info_plist_substitutions(name):
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": name,
"PRODUCT_BUNDLE_IDENTIFIER": "org.telegram.Telegram-iOS.watchkitapp",
"APP_NAME": "Telegram",
"APP_BUNDLE_ID": "org.telegram.Telegram-iOS",
"PRODUCT_NAME": name,
"CURRENT_PROJECT_VERSION": "1",
"CODE_SIGN_IDENTITY": "iPhone Developer: Peter Iakovlev (9J4EJ3F97G)",
"BUILD_NUMBER": appConfig()["buildNumber"],
"BUILD_NUMBER": get_build_number(),
}
return substitutions

View File

@ -1,14 +1,40 @@
.PHONY : check_env build build_arm64 package_arm64 build_buckdebug build_verbose kill_xcode clean project project_buckdebug
.PHONY : check_env build build_arm64 package_arm64 app_arm64 build_buckdebug build_verbose kill_xcode clean project project_buckdebug
BUCK_OPTIONS=\
--config custom.apiId="${TELEGRAM_API_ID}" \
--config custom.apiHash="${TELGRAM_API_HASH}" \
--config custom.hockeyAppId="${TELGRAM_HOCKEYAPP_ID}" \
--config custom.isInternalBuild="${TELEGRAM_IS_INTERNAL_BUILD}" \
--config custom.isAppStoreBuild="${TELEGRAM_IS_APPSTORE_BUILD}" \
--config custom.appStoreId="${TELEGRAM_APPSTORE_ID}" \
--config custom.appSpecificUrlScheme="${TELEGRAM_APP_SPECIFIC_URL_SCHEME}" \
--config custom.buildNumber="${TELEGRAM_BUILD_NUMBER}"
--config custom.developmentCodeSignIdentity="${DEVELOPMENT_CODE_SIGN_IDENTITY}" \
--config custom.distributionCodeSignIdentity="${DISTRIBUTION_CODE_SIGN_IDENTITY}" \
--config custom.developmentTeam="${DEVELOPMENT_TEAM}" \
--config custom.baseApplicationBundleId="${BUNDLE_ID}" \
--config custom.apiId="${API_ID}" \
--config custom.apiHash="${API_HASH}" \
--config custom.hockeyAppId="${HOCKEYAPP_ID}" \
--config custom.isInternalBuild="${IS_INTERNAL_BUILD}" \
--config custom.isAppStoreBuild="${IS_APPSTORE_BUILD}" \
--config custom.appStoreId="${APPSTORE_ID}" \
--config custom.appSpecificUrlScheme="${APP_SPECIFIC_URL_SCHEME}" \
--config custom.buildNumber="${BUILD_NUMBER}" \
--config custom.entitlementsApp="${ENTITLEMENTS_APP}" \
--config custom.developmentProvisioningProfileApp="${DEVELOPMENT_PROVISIONING_PROFILE_APP}" \
--config custom.distributionProvisioningProfileApp="${DISTRIBUTION_PROVISIONING_PROFILE_APP}" \
--config custom.entitlementsExtensionShare="${ENTITLEMENTS_EXTENSION_SHARE}" \
--config custom.developmentProvisioningProfileExtensionShare="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_SHARE}" \
--config custom.distributionProvisioningProfileExtensionShare="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_SHARE}" \
--config custom.entitlementsExtensionWidget="${ENTITLEMENTS_EXTENSION_WIDGET}" \
--config custom.developmentProvisioningProfileExtensionWidget="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_WIDGET}" \
--config custom.distributionProvisioningProfileExtensionWidget="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_WIDGET}" \
--config custom.entitlementsExtensionNotificationService="${ENTITLEMENTS_EXTENSION_NOTIFICATIONSERVICE}" \
--config custom.developmentProvisioningProfileExtensionNotificationService="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONSERVICE}" \
--config custom.distributionProvisioningProfileExtensionNotificationService="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONSERVICE}" \
--config custom.entitlementsExtensionNotificationContent="${ENTITLEMENTS_EXTENSION_NOTIFICATIONCONTENT}" \
--config custom.developmentProvisioningProfileExtensionNotificationContent="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONCONTENT}" \
--config custom.distributionProvisioningProfileExtensionNotificationContent="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONCONTENT}" \
--config custom.entitlementsExtensionIntents="${ENTITLEMENTS_EXTENSION_INTENTS}" \
--config custom.developmentProvisioningProfileExtensionIntents="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_INTENTS}" \
--config custom.distributionProvisioningProfileExtensionIntents="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_INTENTS}" \
--config custom.developmentProvisioningProfileWatchApp="${DEVELOPMENT_PROVISIONING_PROFILE_WATCH_APP}" \
--config custom.distributionProvisioningProfileWatchApp="${DISTRIBUTION_PROVISIONING_PROFILE_WATCH_APP}" \
--config custom.developmentProvisioningProfileWatchExtension="${DEVELOPMENT_PROVISIONING_PROFILE_WATCH_EXTENSION}" \
--config custom.distributionProvisioningProfileWatchExtension="${DISTRIBUTION_PROVISIONING_PROFILE_WATCH_EXTENSION}"
BUCK=/Users/peter/build/buck-next/buck/buck-out/gen/programs/buck.pex
@ -17,14 +43,31 @@ check_env:
build: check_env
$(BUCK) build //:AppPackage#iphoneos-arm64,iphoneos-armv7 ${BUCK_OPTIONS}
sh package_app.sh $(BUCK) "${BUCK_OPTIONS}" iphoneos-arm64,iphoneos-armv7
sh package_app.sh iphoneos-arm64,iphoneos-armv7 $(BUCK) ${BUCK_OPTIONS}
build_arm64: check_env
$(BUCK) build //:AppPackage#iphoneos-arm64 ${BUCK_OPTIONS}
sh package_app.sh $(BUCK) "${BUCK_OPTIONS}" iphoneos-arm64
package_arm64:
sh package_app.sh $(BUCK) "${BUCK_OPTIONS}" iphoneos-arm64
PACKAGE_DEVELOPMENT_TEAM="${DEVELOPMENT_TEAM}" \
PACKAGE_CODE_SIGN_IDENTITY="${DISTRIBUTION_CODE_SIGN_IDENTITY}" \
PACKAGE_PROVISIONING_PROFILE_APP="${DISTRIBUTION_PROVISIONING_PROFILE_APP}" \
PACKAGE_ENTITLEMENTS_APP="${ENTITLEMENTS_APP}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Share="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_SHARE}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Share="${ENTITLEMENTS_EXTENSION_SHARE}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Widget="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_WIDGET}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Widget="${ENTITLEMENTS_EXTENSION_WIDGET}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_NotificationService="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONSERVICE}" \
PACKAGE_ENTITLEMENTS_EXTENSION_NotificationService="${ENTITLEMENTS_EXTENSION_NOTIFICATIONSERVICE}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_NotificationContent="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONCONTENT}" \
PACKAGE_ENTITLEMENTS_EXTENSION_NotificationContent="${ENTITLEMENTS_EXTENSION_NOTIFICATIONCONTENT}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Intents="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_INTENTS}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Intents="${ENTITLEMENTS_EXTENSION_INTENTS}" \
PACKAGE_PROVISIONING_PROFILE_WATCH_APP="${DISTRIBUTION_PROVISIONING_PROFILE_WATCH_APP}" \
PACKAGE_PROVISIONING_PROFILE_WATCH_EXTENSION="${DISTRIBUTION_PROVISIONING_PROFILE_WATCH_EXTENSION}" \
sh package_app.sh iphoneos-arm64 $(BUCK) $(BUCK_OPTIONS)
app_arm64: build_arm64 package_arm64
build_buckdebug: check_env
BUCK_DEBUG_MODE=1 $(BUCK) build //:AppPackage#iphoneos-arm64 ${BUCK_OPTIONS}

View File

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>5.11</string>
<key>CFBundleVersion</key>
<string>99999</string>
<string>${BUILD_NUMBER}</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>

View File

@ -223,7 +223,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>99999</string>
<string>${BUILD_NUMBER}</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>

View File

@ -29,5 +29,9 @@
<string>$(APP_BUNDLE_ID)</string>
<key>WKWatchKitApp</key>
<true/>
<key>UIDeviceFamily</key>
<array>
<integer>4</integer>
</array>
</dict>
</plist>

View File

@ -3,14 +3,10 @@
set -x
set -e
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: sh package_app.sh path/to/buck platform-flavors"
exit 1
fi
BUCK="$1"
BUCK_OPTIONS="$2"
PLATFORM_FLAVORS="$3"
PLATFORM_FLAVORS="$1"
BUCK="$2"
shift
shift
BUILD_PATH="build"
APP_NAME="Telegram"
@ -20,11 +16,18 @@ DSYMS_FOLDER_NAME="DSYMs"
DSYMS_ZIP="$BUILD_PATH/$DSYMS_FOLDER_NAME.zip"
DSYMS_DIR="$BUILD_PATH/$DSYMS_FOLDER_NAME"
TEMP_PATH="$BUILD_PATH/temp"
TEMP_ENTITLEMENTS_PATH="$TEMP_PATH/entitlements"
mkdir -p "$BUILD_PATH"
rm -f "$IPA_PATH"
rm -f "$DSYMS_ZIP"
rm -rf "$DSYMS_DIR"
mkdir -p "$DSYMS_DIR"
rm -rf "$TEMP_PATH"
mkdir -p "$TEMP_PATH"
mkdir -p "$TEMP_ENTITLEMENTS_PATH"
cp "buck-out/gen/AppPackage#$PLATFORM_FLAVORS.ipa" "$IPA_PATH.original"
rm -rf "$IPA_PATH.original.unpacked"
@ -32,6 +35,7 @@ rm -f "$BUILD_PATH/${APP_NAME}_signed.ipa"
mkdir -p "$IPA_PATH.original.unpacked"
unzip "$IPA_PATH.original" -d "$IPA_PATH.original.unpacked/"
rm "$IPA_PATH.original"
rm -f "$KEYCHAIN_PATH"
UNPACKED_PATH="$IPA_PATH.original.unpacked"
APP_PATH="$UNPACKED_PATH/Payload/Telegram.app"
@ -41,25 +45,118 @@ rm -rf "$IPA_PATH.original.unpacked/SwiftSupport/iphoneos/"*
rm -rf "$IPA_PATH.original.unpacked/Symbols/"*
rm -rf "$FRAMEWORKS_DIR/"*
for DEPENDENCY in $(${BUCK} query "kind('apple_library|apple_binary', deps('//:Telegram#$PLATFORM_FLAVORS', 1))" ${BUCK_OPTIONS}); do
case "$DEPENDENCY" in
*"#"*)
;;
*)
DEPENDENCY="$DEPENDENCY#$PLATFORM_FLAVORS"
;;
esac
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: sh package_app.sh path/to/buck platform-flavors"
exit 1
fi
if [ -z "$PACKAGE_CODE_SIGN_IDENTITY" ]; then
echo "PACKAGE_CODE_SIGN_IDENTITY is not set"
exit 1
fi
if [ -z "$DEVELOPMENT_TEAM" ]; then
echo "DEVELOPMENT_TEAM is not set"
exit 1
fi
if [ ! -d "$CODESIGNING_DATA_PATH" ]; then
echo "CODESIGNING_DATA_PATH $CODESIGNING_DATA_PATH does not exist"
exit 1
fi
APP_ITEMS_WITH_PROVISIONING_PROFILE="APP EXTENSION_Share EXTENSION_Widget EXTENSION_NotificationService EXTENSION_NotificationContent EXTENSION_Intents WATCH_APP WATCH_EXTENSION"
APP_ITEMS_WITH_ENTITLEMENTS="APP EXTENSION_Share EXTENSION_Widget EXTENSION_NotificationService EXTENSION_NotificationContent EXTENSION_Intents"
COMMON_IDENTITY_HASH=""
for ITEM in $APP_ITEMS_WITH_PROVISIONING_PROFILE; do
PROFILE_VAR=PACKAGE_PROVISIONING_PROFILE_$ITEM
if [ -z "${!PROFILE_VAR}" ]; then
echo "$PROFILE_VAR is not set"
exit 1
fi
for PROFILE in "$CODESIGNING_DATA_PATH/profiles/"*; do
PROFILE_DATA=$(security cms -D -i "$PROFILE")
PROFILE_NAME=$(/usr/libexec/PlistBuddy -c "Print :Name" /dev/stdin <<< $(echo $PROFILE_DATA))
if [ "$PROFILE_NAME" == "${!PROFILE_VAR}" ]; then
TEAM_IDENTIFIER=$(/usr/libexec/PlistBuddy -c "Print :Entitlements:com.apple.developer.team-identifier" /dev/stdin <<< $(echo $PROFILE_DATA))
if [ "$TEAM_IDENTIFIER" != "$DEVELOPMENT_TEAM" ]; then
"Entitlements:com.apple.developer.team-identifier in $PROFILE does not match $DEVELOPMENT_TEAM"
fi
echo $(/usr/libexec/PlistBuddy -c "Print :DeveloperCertificates:0 :data" /dev/stdin <<< $(echo $PROFILE_DATA)) > cert.pem
IDENTITY_NAME=$(/usr/libexec/PlistBuddy -c "Print :DeveloperCertificates:0 :data" /dev/stdin <<< $(echo $PROFILE_DATA) | openssl x509 -inform DER -subject -nameopt multiline -sha1 -noout | grep commonName | sed -e 's#[ ]*commonName[ ]*=[ ]*##g')
if [ ! -z "$IDENTITY_NAME" ]; then
IDENTITY_HASH=$(/usr/libexec/PlistBuddy -c "Print :DeveloperCertificates:0 :data" /dev/stdin <<< $(echo $PROFILE_DATA) | openssl x509 -inform DER -fingerprint -sha1 -noout | sed -e 's#SHA1 Fingerprint=##' | sed -e 's#:##g')
if [ -z "$COMMON_IDENTITY_HASH" ]; then
COMMON_IDENTITY_HASH="$IDENTITY_HASH"
elif [ "$COMMON_IDENTITY_HASH" != "$IDENTITY_HASH" ]; then
"Signing identity in $PROFILE ($IDENTITY_HASH) does not match $COMMON_IDENTITY_HASH from previously processed profiles"
fi
else
echo "Signing identity name in $PROFILE does not match $PACKAGE_CODE_SIGN_IDENTITY"
exit 1
fi
declare PROFILE_PATH_$ITEM="$PROFILE"
PROFILE_ENTITLEMENTS_PATH="$TEMP_ENTITLEMENTS_PATH/$ITEM.entitlements"
security cms -D -i "$PROFILE" > "$TEMP_PATH/temp.plist" && /usr/libexec/PlistBuddy -x -c 'Print:Entitlements' "$TEMP_PATH/temp.plist" > "$PROFILE_ENTITLEMENTS_PATH"
declare ENTITLEMENTS_PATH_$ITEM="$PROFILE_ENTITLEMENTS_PATH"
fi
done
done
for ITEM in $APP_ITEMS_WITH_PROVISIONING_PROFILE; do
PROFILE_PATH_VAR=PROFILE_PATH_$ITEM
if [ -z "${!PROFILE_PATH_VAR}" ]; then
echo "Provisioning profile for $ITEM was not found"
exit 1
fi
done
for ITEM in $APP_ITEMS_WITH_ENTITLEMENTS; do
ENTITLEMENTS_VAR=PACKAGE_ENTITLEMENTS_$ITEM
if [ -z "${!ENTITLEMENTS_VAR}" ]; then
echo "$ENTITLEMENTS_VAR is not set"
exit 1
fi
if [ ! -f "${!ENTITLEMENTS_VAR}" ]; then
echo "${!ENTITLEMENTS_VAR} does not exist"
exit 1
fi
#declare ENTITLEMENTS_PATH_$ITEM="${!ENTITLEMENTS_VAR}"
done
if [ -z "$COMMON_IDENTITY_HASH" ]; then
echo "Failed to determine signing identity"
exit 1
fi
for DEPENDENCY in $(${BUCK} query "kind('apple_library', deps('//:Telegram#$PLATFORM_FLAVORS', 1))" "$@"); do
DEPENDENCY_PATH=$(echo "$DEPENDENCY" | sed -e "s#^//##" | sed -e "s#:#/#")
DEPENDENCY_NAME=$(echo "$DEPENDENCY" | sed -e "s/#.*//" | sed -e "s/^.*\://")
DYLIB_PATH="buck-out/gen/$DEPENDENCY_PATH/lib$DEPENDENCY_NAME.dylib"
if [ -f "$DYLIB_PATH" ]; then
TARGET_DYLIB_PATH="$FRAMEWORKS_DIR/lib$DEPENDENCY_NAME.dylib"
cp "$DYLIB_PATH" "$TARGET_DYLIB_PATH"
fi
TARGET_DYLIB_PATH="$FRAMEWORKS_DIR/lib$DEPENDENCY_NAME.dylib"
cp "$DYLIB_PATH" "$TARGET_DYLIB_PATH"
DSYM_PATH="buck-out/gen/$(echo "$DEPENDENCY" | sed -e "s/#/#apple-dsym,/" | sed -e "s#^//##" | sed -e "s#:#/#").dSYM"
cp -f -r "$DSYM_PATH" "$DSYMS_DIR/"
cp -r "$DSYM_PATH" "$DSYMS_DIR/"
done
APP_BINARY_DSYM_PATH="buck-out/gen/Telegram#dwarf-and-dsym,$PLATFORM_FLAVORS,no-include-frameworks/Telegram.app.dSYM"
cp -r "$APP_BINARY_DSYM_PATH" "$DSYMS_DIR/"
EXTENSIONS="Share Widget Intents NotificationContent NotificationService"
for EXTENSION in $EXTENSIONS; do
EXTENSION_DSYM_PATH="buck-out/gen/${EXTENSION}Extension#dwarf-and-dsym,$PLATFORM_FLAVORS,no-include-frameworks/${EXTENSION}Extension.appex.dSYM"
cp -r "$EXTENSION_DSYM_PATH" "$DSYMS_DIR/"
done
WATCH_EXTENSION_DSYM_PATH="buck-out/gen/WatchAppExtension#dwarf-and-dsym,no-include-frameworks,watchos-arm64_32,watchos-armv7k/WatchAppExtension.appex.dSYM"
cp -r "$WATCH_EXTENSION_DSYM_PATH" "$DSYMS_DIR/"
for LIB in $(ls "$FRAMEWORKS_DIR"/*.dylib); do
strip -S -T "$LIB"
done
@ -75,27 +172,114 @@ done
cp "$IPA_PATH.original.unpacked/SwiftSupport/iphoneos/"*.dylib "$FRAMEWORKS_DIR/"
CERTIFICATE="76F9BA5C281AA72599FE015E0CE1A5D82F5A3DED"
for framework in "$FRAMEWORKS_DIR"/*; do
if [[ "$framework" == *.framework || "$framework" == *.dylib ]]; then
/usr/bin/codesign ${VERBOSE} ${KEYCHAIN_FLAG} -f -s "$CERTIFICATE" "$framework"
else
log "Ignoring non-framework: $framework"
/usr/bin/codesign ${VERBOSE} ${KEYCHAIN_FLAG} -f -s "$COMMON_IDENTITY_HASH" "$framework"
fi
done
PROVISIONING_PROFILE="buildbox/transient-data/codesigning/profiles/InHouse_org.telegram.Telegram-iOS.mobileprovision"
cp "$PROVISIONING_PROFILE" "$APP_PATH/embedded.mobileprovision"
PLUGINS="Share Widget Intents NotificationService NotificationContent"
for PLUGIN in $PLUGINS; do
PLUGIN_PATH="$APP_PATH/PlugIns/${PLUGIN}Extension.appex"
if [ ! -d "$PLUGIN_PATH" ]; then
echo "Directory at $PLUGIN_PATH does not exist"
exit 1
fi
PROFILE_PATH_VAR="PROFILE_PATH_EXTENSION_$PLUGIN"
if [ -z "${!PROFILE_PATH_VAR}" ]; then
echo "$PROFILE_PATH_VAR is not defined"
exit 1
fi
if [ ! -f "${!PROFILE_PATH_VAR}" ]; then
echo "${!PROFILE_PATH_VAR} does not exist"
exit 1
fi
ENTITLEMENTS_PATH_VAR="ENTITLEMENTS_PATH_EXTENSION_$PLUGIN"
if [ -z "${!ENTITLEMENTS_PATH_VAR}" ]; then
echo "$ENTITLEMENTS_PATH_VAR is not defined"
exit 1
fi
if [ ! -f "${!ENTITLEMENTS_PATH_VAR}" ]; then
echo "${!ENTITLEMENTS_PATH_VAR} does not exist"
exit 1
fi
cp "${!PROFILE_PATH_VAR}" "$PLUGIN_PATH/embedded.mobileprovision"
/usr/bin/codesign ${VERBOSE} -f -s "$COMMON_IDENTITY_HASH" --entitlements "${!ENTITLEMENTS_PATH_VAR}" "$PLUGIN_PATH"
done
ENTITLEMENTS="Entitlements.entitlements"
WATCH_APP_PATH="$APP_PATH/Watch/WatchApp.app"
WATCH_EXTENSION_PATH="$WATCH_APP_PATH/PlugIns/WatchAppExtension.appex"
/usr/bin/codesign ${VERBOSE} -f -s "$CERTIFICATE" --entitlements "$ENTITLEMENTS" "$APP_PATH"
WATCH_EXTENSION_PROFILE_PATH_VAR="PROFILE_PATH_WATCH_EXTENSION"
if [ -z "${!WATCH_EXTENSION_PROFILE_PATH_VAR}" ]; then
echo "$WATCH_EXTENSION_PROFILE_PATH_VAR is not defined"
exit 1
fi
if [ ! -f "${!WATCH_EXTENSION_PROFILE_PATH_VAR}" ]; then
echo "${!WATCH_EXTENSION_PROFILE_PATH_VAR} does not exist"
exit 1
fi
WATCH_EXTENSION_ENTITLEMENTS_PATH_VAR="ENTITLEMENTS_PATH_WATCH_EXTENSION"
if [ -z "${!WATCH_EXTENSION_ENTITLEMENTS_PATH_VAR}" ]; then
echo "$WATCH_EXTENSION_ENTITLEMENTS_PATH_VAR is not defined"
exit 1
fi
if [ ! -f "${!WATCH_EXTENSION_ENTITLEMENTS_PATH_VAR}" ]; then
echo "${!WATCH_EXTENSION_ENTITLEMENTS_PATH_VAR} does not exist"
exit 1
fi
cp "${!WATCH_EXTENSION_PROFILE_PATH_VAR}" "$WATCH_EXTENSION_PATH/embedded.mobileprovision"
/usr/bin/codesign ${VERBOSE} -f -s "$COMMON_IDENTITY_HASH" --entitlements "${!WATCH_EXTENSION_ENTITLEMENTS_PATH_VAR}" "$WATCH_EXTENSION_PATH"
WATCH_APP_PROFILE_PATH_VAR="PROFILE_PATH_WATCH_APP"
if [ -z "${!WATCH_APP_PROFILE_PATH_VAR}" ]; then
echo "$WATCH_APP_PROFILE_PATH_VAR is not defined"
exit 1
fi
if [ ! -f "${!WATCH_APP_PROFILE_PATH_VAR}" ]; then
echo "${!WATCH_APP_PROFILE_PATH_VAR} does not exist"
exit 1
fi
WATCH_APP_ENTITLEMENTS_PATH_VAR="ENTITLEMENTS_PATH_WATCH_APP"
if [ -z "${!WATCH_APP_ENTITLEMENTS_PATH_VAR}" ]; then
echo "$WATCH_APP_ENTITLEMENTS_PATH_VAR is not defined"
exit 1
fi
if [ ! -f "${!WATCH_APP_ENTITLEMENTS_PATH_VAR}" ]; then
echo "${!WATCH_APP_ENTITLEMENTS_PATH_VAR} does not exist"
exit 1
fi
cp "${!WATCH_APP_PROFILE_PATH_VAR}" "$WATCH_APP_PATH/embedded.mobileprovision"
/usr/bin/codesign ${VERBOSE} -f -s "$COMMON_IDENTITY_HASH" --entitlements "${!WATCH_APP_ENTITLEMENTS_PATH_VAR}" "$WATCH_APP_PATH"
APP_PROFILE_PATH_VAR="PROFILE_PATH_APP"
if [ -z "${!APP_PROFILE_PATH_VAR}" ]; then
echo "$APP_PROFILE_PATH_VAR is not defined"
exit 1
fi
if [ ! -f "${!APP_PROFILE_PATH_VAR}" ]; then
echo "${!APP_PROFILE_PATH_VAR} does not exist"
exit 1
fi
APP_ENTITLEMENTS_PATH_VAR="ENTITLEMENTS_PATH_APP"
if [ -z "${!APP_ENTITLEMENTS_PATH_VAR}" ]; then
echo "$APP_ENTITLEMENTS_PATH_VAR is not defined"
exit 1
fi
if [ ! -f "${!APP_ENTITLEMENTS_PATH_VAR}" ]; then
echo "${!APP_ENTITLEMENTS_PATH_VAR} does not exist"
exit 1
fi
cp "${!APP_PROFILE_PATH_VAR}" "$APP_PATH/embedded.mobileprovision"
/usr/bin/codesign ${VERBOSE} -f -s "$COMMON_IDENTITY_HASH" --entitlements "${!APP_ENTITLEMENTS_PATH_VAR}" "$APP_PATH"
DIR=$(pwd)
cd "$UNPACKED_PATH"
zip -r "../${APP_NAME}_signed.ipa" Payload SwiftSupport
zip -r "../${APP_NAME}_signed.ipa" Payload #SwiftSupport WatchKitSupport2
cd "$DIR"
cd "$BUILD_PATH"