Merge commit '30abc85d1bff9c03c2ed2db5dc29e8c6057b571b' into beta

This commit is contained in:
Ali 2021-01-15 12:19:35 +04:00
commit ab3977b1a5
13 changed files with 3 additions and 1767 deletions

View File

View File

@ -1,20 +0,0 @@
def appConfig():
apiId = native.read_config("custom", "apiId")
apiHash = native.read_config("custom", "apiHash")
appCenterId = native.read_config("custom", "appCenterId")
isInternalBuild = native.read_config("custom", "isInternalBuild")
isAppStoreBuild = native.read_config("custom", "isAppStoreBuild")
appStoreId = native.read_config("custom", "appStoreId")
appSpecificUrlScheme = native.read_config("custom", "appSpecificUrlScheme")
buildNumber = native.read_config("custom", "buildNumber")
return {
"apiId": apiId,
"apiHash": apiHash,
"appCenterId": appCenterId,
"isInternalBuild": isInternalBuild,
"isAppStoreBuild": isAppStoreBuild,
"appStoreId": appStoreId,
"appSpecificUrlScheme": appSpecificUrlScheme,
"buildNumber": buildNumber,
}

View File

@ -1,318 +0,0 @@
load("//Config:utils.bzl",
"config_with_updated_linker_flags",
"configs_with_config",
"merge_dict",
"DEVELOPMENT_LANGUAGE",
"SHARED_CONFIGS",
"ALL_LOAD_LINKER_FLAG",
"read_config_nonempty",
"optimization_config",
"add_provisioning_profile_specifier",
"add_codesign_identity",
"get_build_number",
"get_short_version",
"bundle_identifier",
"get_development_team",
"get_provisioning_profile",
"get_codesign_entitlements",
)
load("//Config:app_configuration.bzl",
"appConfig",
)
def app_binary_configs():
config = {
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES": "YES",
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"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": get_build_number(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"APP_NAME": "Telegram",
"PRODUCT_NAME": "Telegram",
"TARGETED_DEVICE_FAMILY": "1,2",
}
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():
config = {
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES": "NO",
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".Share"),
"CODE_SIGN_ENTITLEMENTS": get_codesign_entitlements("share"),
"DEVELOPMENT_TEAM": get_development_team(),
"BUILD_NUMBER": get_build_number(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"APP_NAME": "Telegram",
"PRODUCT_NAME": "ShareExtension",
}
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():
config = {
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES": "NO",
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".Widget"),
"CODE_SIGN_ENTITLEMENTS": get_codesign_entitlements("widget"),
"DEVELOPMENT_TEAM": get_development_team(),
"BUILD_NUMBER": get_build_number(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"APP_NAME": "Telegram",
"PRODUCT_NAME": "WidgetExtension",
}
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():
config = {
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES": "NO",
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"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(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"APP_NAME": "Telegram",
"PRODUCT_NAME": "NotificationContentExtension",
}
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():
config = {
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES": "NO",
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"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(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"APP_NAME": "Telegram",
"PRODUCT_NAME": "NotificationServiceExtension",
}
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():
config = {
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES": "NO",
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".SiriIntents"),
"CODE_SIGN_ENTITLEMENTS": get_codesign_entitlements("intents"),
"DEVELOPMENT_TEAM": get_development_team(),
"BUILD_NUMBER": get_build_number(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"APP_NAME": "Telegram",
"PRODUCT_NAME": "IntentsExtension",
}
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():
config = {
"SDKROOT": "watchos",
"WATCHOS_DEPLOYMENT_TARGET": "5.0",
"TARGETED_DEVICE_FAMILY": "4",
"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": bundle_identifier(suffix=""),
"WK_APP_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".watchkitapp"),
"APP_NAME": "Telegram",
"APP_BUNDLE_ID": bundle_identifier(suffix=""),
"BUILD_NUMBER": get_build_number(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"ENABLE_BITCODE": "YES",
}
config = config_with_updated_linker_flags(config, ALL_LOAD_LINKER_FLAG)
configs = configs_with_config(config)
configs = add_provisioning_profile_specifier(configs, "watch_extension")
configs = add_codesign_identity(configs)
return configs
def watch_binary_configs():
config = {
"SDKROOT": "watchos",
"WATCHOS_DEPLOYMENT_TARGET": "5.0",
"TARGETED_DEVICE_FAMILY": "4",
"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": bundle_identifier(suffix=""),
"WK_APP_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".watchkitapp"),
"APP_NAME": "Telegram",
"APP_BUNDLE_ID": bundle_identifier(suffix=""),
"ASSETCATALOG_COMPILER_APPICON_NAME": "AppIcon",
"BUILD_NUMBER": get_build_number(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"ENABLE_BITCODE": "YES",
}
config = config_with_updated_linker_flags(config, ALL_LOAD_LINKER_FLAG)
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 = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": name,
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(name),
"PRODUCT_NAME": name,
"CURRENT_PROJECT_VERSION": "1",
}
return substitutions
def app_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": "Telegram",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=""),
"PRODUCT_NAME": "Telegram",
"APP_NAME": "Telegram",
"CURRENT_PROJECT_VERSION": "1",
"APP_SPECIFIC_URL_SCHEME": appConfig()["appSpecificUrlScheme"],
"BUILD_NUMBER": get_build_number(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"ASSETCATALOG_COMPILER_APPICON_NAME": "AppIcon",
"TARGETED_DEVICE_FAMILY": "1,2",
}
return substitutions
def share_extension_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": "ShareExtension",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".Share"),
"PRODUCT_NAME": "Share",
"APP_NAME": "Telegram",
"CURRENT_PROJECT_VERSION": "1",
"APP_SPECIFIC_URL_SCHEME": appConfig()["appSpecificUrlScheme"],
"BUILD_NUMBER": get_build_number(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
}
return substitutions
def widget_extension_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": "WidgetExtension",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".Widget"),
"PRODUCT_NAME": "Widget",
"APP_NAME": "Telegram",
"CURRENT_PROJECT_VERSION": "1",
"APP_SPECIFIC_URL_SCHEME": appConfig()["appSpecificUrlScheme"],
"BUILD_NUMBER": get_build_number(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"MinimumOSVersion": "9.0",
}
return substitutions
def notification_content_extension_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"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(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"MinimumOSVersion": "10.0",
}
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(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"MinimumOSVersion": "10.0",
}
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",
"APP_SPECIFIC_URL_SCHEME": appConfig()["appSpecificUrlScheme"],
"BUILD_NUMBER": get_build_number(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"PRODUCT_MODULE_NAME": "SiriIntents",
"MinimumOSVersion": "10.0",
}
return substitutions
def watch_extension_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"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",
"BUILD_NUMBER": get_build_number(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"MinimumOSVersion": "5.0",
}
return substitutions
def watch_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"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",
"BUILD_NUMBER": get_build_number(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"MinimumOSVersion": "5.0",
}
return substitutions

View File

@ -1,31 +0,0 @@
def _impl(ctx):
output_dir = ctx.attr.name + "_ModuleHeaders"
dir = ctx.actions.declare_directory(output_dir)
files = []
files_command = ""
for file in ctx.files.headers:
outFile = ctx.actions.declare_file(output_dir + "/" + ctx.attr.module_name + "/" + file.basename)
files.append(outFile)
files_command = files_command + " && cp " + file.path + " " + outFile.path
ctx.actions.run_shell(
outputs = [dir] + files,
inputs = ctx.files.headers,
command = "mkdir -p " + dir.path + " " + files_command
)
return [
apple_common.new_objc_provider(
include_system = depset([dir.path]),
header = depset(files),
),
]
objc_module = rule(
implementation = _impl,
attrs = {
"module_name": attr.string(mandatory = True),
"headers": attr.label_list(
allow_files = [".h"],
),
},
)

View File

@ -1,202 +0,0 @@
OTHER_LINKER_FLAGS_KEY = 'OTHER_LDFLAGS'
def configs_with_config(config):
return {
"Debug": config,
"Profile": config,
"Release": config,
}
def configs_with_updated_linker_flags(configs, other_linker_flags):
if other_linker_flags == None:
return configs
else:
updated_configs = { }
for build_configuration in configs:
updated_configs[build_configuration] = config_with_updated_linker_flags(
configs[build_configuration],
other_linker_flags)
return updated_configs
def config_with_updated_linker_flags(config, other_linker_flags, config_key=OTHER_LINKER_FLAGS_KEY):
new_config = { }
config_key_found = False
for key in config:
if key == config_key:
new_config[key] = config[key] + (" %s" % other_linker_flags)
config_key_found = True
else:
new_config[key] = config[key]
if config_key_found == False:
# If `config` does not currently contain `config_key`, add it. Inherit for good measure.
new_config[config_key] = '$(inherited) ' + other_linker_flags
return new_config
def merge_dict(a, b):
d = {}
d.update(a)
d.update(b)
return d
DEVELOPMENT_LANGUAGE = "en"
SHARED_CONFIGS = {
"IPHONEOS_DEPLOYMENT_TARGET": "9.0",
"SDKROOT": "iphoneos",
"GCC_OPTIMIZATION_LEVEL": "0",
"SWIFT_WHOLE_MODULE_OPTIMIZATION": "NO",
"ONLY_ACTIVE_ARCH": "YES",
"LD_RUNPATH_SEARCH_PATHS": "@executable_path/Frameworks",
"ENABLE_BITCODE": "NO",
}
# Adding `-all_load` to our binaries works around https://bugs.swift.org/browse/SR-6004.
ALL_LOAD_LINKER_FLAG = "-all_load"
def optimization_config():
return {
"SWIFT_OPTIMIZATION_LEVEL": native.read_config("custom", "optimization"),
}
def read_config_nonempty(name):
value = native.read_config("custom", name)
if value == None:
fail("Configuration parameter custom.%s should be defined" % name)
elif len(value) == 0:
fail("Configuration parameter 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_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_build_number():
return read_config_nonempty("buildNumber")
def get_short_version():
return read_config_nonempty("appVersion")
def bundle_identifier(suffix):
return read_config_nonempty("baseApplicationBundleId") + suffix
def library_configs():
lib_specific_config = {
"SWIFT_WHOLE_MODULE_OPTIMIZATION": "NO",
# Setting SKIP_INSTALL to NO for static library configs would create
# create a generic xcode archive which can not be uploaded the app store
# https://developer.apple.com/library/archive/technotes/tn2215/_index.html
"SKIP_INSTALL": "YES",
}
library_config = merge_dict(SHARED_CONFIGS, lib_specific_config)
library_config = merge_dict(library_config, optimization_config())
configs = {
"Debug": library_config,
"Profile": library_config,
"Release": library_config,
}
return configs
def dynamic_library_configs():
lib_specific_config = {
"SWIFT_WHOLE_MODULE_OPTIMIZATION": "NO",
# Setting SKIP_INSTALL to NO for static library configs would create
# create a generic xcode archive which can not be uploaded the app store
# https://developer.apple.com/library/archive/technotes/tn2215/_index.html
"SKIP_INSTALL": "YES",
"MACH_O_TYPE": "mh_dylib",
"CODE_SIGNING_ALLOWED": "NO",
}
library_config = merge_dict(SHARED_CONFIGS, lib_specific_config)
library_config = merge_dict(library_config, optimization_config())
configs = {
"Debug": library_config,
"Profile": library_config,
"Release": library_config,
}
return configs
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_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")

View File

@ -1,59 +0,0 @@
load("//Config:utils.bzl",
"config_with_updated_linker_flags",
"configs_with_config",
"merge_dict",
"DEVELOPMENT_LANGUAGE",
"SHARED_CONFIGS",
"ALL_LOAD_LINKER_FLAG",
"optimization_config",
"add_provisioning_profile_specifier",
"add_codesign_identity",
"get_build_number",
"get_short_version",
"bundle_identifier",
"get_development_team",
"get_provisioning_profile",
"get_codesign_entitlements",
)
load("//Config:app_configuration.bzl",
"appConfig"
)
def app_binary_configs():
config = {
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES": "YES",
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": "Wallet",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=""),
"CODE_SIGN_ENTITLEMENTS": get_codesign_entitlements("app"),
"DEVELOPMENT_TEAM": get_development_team(),
"ASSETCATALOG_COMPILER_APPICON_NAME": "AppIconWallet",
"BUILD_NUMBER": get_build_number(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"APP_NAME": "TON Wallet",
"PRODUCT_NAME": "TON Wallet",
"TARGETED_DEVICE_FAMILY": "1,2",
}
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 app_info_plist_substitutions():
substitutions = {
"DEVELOPMENT_LANGUAGE": DEVELOPMENT_LANGUAGE,
"EXECUTABLE_NAME": "Wallet",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=""),
"PRODUCT_NAME": "TON Wallet",
"APP_NAME": "TON Wallet",
"CURRENT_PROJECT_VERSION": "1",
"BUILD_NUMBER": get_build_number(),
"PRODUCT_BUNDLE_SHORT_VERSION": get_short_version(),
"ASSETCATALOG_COMPILER_APPICON_NAME": "AppIconWallet",
"TARGETED_DEVICE_FAMILY": "1,2",
}
return substitutions

471
Makefile
View File

@ -1,471 +0,0 @@
.PHONY : check_env build build_arm64 build_debug_arm64 package package_arm64 app app_arm64 app_debug_arm64 build_buckdebug build_verbose kill_xcode clean project project_buckdebug temp
include Utils.makefile
APP_VERSION="7.3.1"
CORE_COUNT=$(shell sysctl -n hw.logicalcpu)
CORE_COUNT_MINUS_ONE=$(shell expr ${CORE_COUNT} \- 1)
BUCK_OPTIONS=\
--config custom.appVersion="${APP_VERSION}" \
--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.appCenterId="${APP_CENTER_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}"
BAZEL=$(shell which bazel)
ifneq ($(BAZEL_HTTP_CACHE_URL),)
export BAZEL_CACHE_FLAGS=\
--remote_cache="$(BAZEL_HTTP_CACHE_URL)" --experimental_remote_downloader="$(BAZEL_HTTP_CACHE_URL)"
else ifneq ($(BAZEL_CACHE_DIR),)
export BAZEL_CACHE_FLAGS=\
--disk_cache="${BAZEL_CACHE_DIR}"
endif
BAZEL_COMMON_FLAGS=\
--announce_rc \
--features=swift.use_global_module_cache \
--features=swift.split_derived_files_generation \
--features=swift.skip_function_bodies_for_derived_files \
--jobs=${CORE_COUNT}
BAZEL_DEBUG_FLAGS=\
--features=swift.enable_batch_mode \
--swiftcopt=-j${CORE_COUNT_MINUS_ONE} \
# --num-threads 0 forces swiftc to generate one object file per module; it:
# 1. resolves issues with the linker caused by swift-objc mixing.
# 2. makes the resulting binaries significantly smaller (up to 9% for this project).
BAZEL_OPT_FLAGS=\
--features=swift.opt_uses_wmo \
--features=swift.opt_uses_osize \
--swiftcopt='-num-threads' --swiftcopt='0' \
--features=dead_strip \
--objc_enable_binary_stripping \
--apple_bitcode=watchos=embedded \
build_arm64: check_env
$(BUCK) build \
//Telegram:AppPackage#iphoneos-arm64 \
//Telegram:Telegram#dwarf-and-dsym,iphoneos-arm64 \
//submodules/MtProtoKit:MtProtoKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/MtProtoKit:MtProtoKit#shared,iphoneos-arm64 \
//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#shared,iphoneos-arm64 \
//submodules/Postbox:Postbox#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/Postbox:Postbox#shared,iphoneos-arm64 \
//submodules/TelegramApi:TelegramApi#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/TelegramApi:TelegramApi#shared,iphoneos-arm64 \
//submodules/SyncCore:SyncCore#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/SyncCore:SyncCore#shared,iphoneos-arm64 \
//submodules/TelegramCore:TelegramCore#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/TelegramCore:TelegramCore#shared,iphoneos-arm64 \
//submodules/AsyncDisplayKit:AsyncDisplayKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/AsyncDisplayKit:AsyncDisplayKit#shared,iphoneos-arm64 \
//submodules/Display:Display#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/Display:Display#shared,iphoneos-arm64 \
//submodules/TelegramUI:TelegramUI#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/TelegramUI:TelegramUI#shared,iphoneos-arm64 \
//Telegram:WatchAppExtension#dwarf-and-dsym,watchos-arm64_32,watchos-armv7k \
//Telegram:ShareExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:WidgetExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:NotificationContentExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:NotificationServiceExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:IntentsExtension#dwarf-and-dsym,iphoneos-arm64 \
${BUCK_OPTIONS} ${BUCK_RELEASE_OPTIONS} ${BUCK_THREADS_OPTIONS} ${BUCK_CACHE_OPTIONS}
build_debug_arm64: check_env
$(BUCK) build \
//Telegram:AppPackage#iphoneos-arm64 \
//Telegram:Telegram#dwarf-and-dsym,iphoneos-arm64 \
//submodules/MtProtoKit:MtProtoKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/MtProtoKit:MtProtoKit#shared,iphoneos-arm64 \
//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#shared,iphoneos-arm64 \
//submodules/Postbox:Postbox#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/Postbox:Postbox#shared,iphoneos-arm64 \
//submodules/TelegramApi:TelegramApi#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/TelegramApi:TelegramApi#shared,iphoneos-arm64 \
//submodules/SyncCore:SyncCore#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/SyncCore:SyncCore#shared,iphoneos-arm64 \
//submodules/TelegramCore:TelegramCore#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/TelegramCore:TelegramCore#shared,iphoneos-arm64 \
//submodules/AsyncDisplayKit:AsyncDisplayKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/AsyncDisplayKit:AsyncDisplayKit#shared,iphoneos-arm64 \
//submodules/Display:Display#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/Display:Display#shared,iphoneos-arm64 \
//submodules/TelegramUI:TelegramUI#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/TelegramUI:TelegramUI#shared,iphoneos-arm64 \
//Telegram:WatchAppExtension#dwarf-and-dsym,watchos-arm64_32,watchos-armv7k \
//Telegram:ShareExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:WidgetExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:NotificationContentExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:NotificationServiceExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:IntentsExtension#dwarf-and-dsym,iphoneos-arm64 \
${BUCK_OPTIONS} ${BUCK_DEBUG_OPTIONS} ${BUCK_THREADS_OPTIONS} ${BUCK_CACHE_OPTIONS}
build_wallet_debug_arm64: check_env
$(BUCK) build \
//Wallet:AppPackage#iphoneos-arm64 \
//Wallet:Wallet#dwarf-and-dsym,iphoneos-arm64 \
//submodules/MtProtoKit:MtProtoKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/MtProtoKit:MtProtoKit#shared,iphoneos-arm64 \
//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#shared,iphoneos-arm64 \
//submodules/AsyncDisplayKit:AsyncDisplayKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/AsyncDisplayKit:AsyncDisplayKit#shared,iphoneos-arm64 \
//submodules/Display:Display#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/Display:Display#shared,iphoneos-arm64 \
${WALLET_BUCK_OPTIONS} ${BUCK_DEBUG_OPTIONS} ${BUCK_THREADS_OPTIONS} ${BUCK_CACHE_OPTIONS}
build_debug_armv7: check_env
$(BUCK) build \
//Telegram:AppPackage#iphoneos-armv7 \
//Telegram:Telegram#dwarf-and-dsym,iphoneos-armv7 \
//submodules/MtProtoKit:MtProtoKit#dwarf-and-dsym,shared,iphoneos-armv7 \
//submodules/MtProtoKit:MtProtoKit#shared,iphoneos-armv7 \
//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#dwarf-and-dsym,shared,iphoneos-armv7 \
//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#shared,iphoneos-armv7 \
//submodules/Postbox:Postbox#dwarf-and-dsym,shared,iphoneos-armv7 \
//submodules/Postbox:Postbox#shared,iphoneos-armv7 \
//submodules/TelegramApi:TelegramApi#dwarf-and-dsym,shared,iphoneos-armv7 \
//submodules/TelegramApi:TelegramApi#shared,iphoneos-armv7 \
//submodules/SyncCore:SyncCore#dwarf-and-dsym,shared,iphoneos-armv7 \
//submodules/SyncCore:SyncCore#shared,iphoneos-armv7 \
//submodules/TelegramCore:TelegramCore#dwarf-and-dsym,shared,iphoneos-armv7 \
//submodules/TelegramCore:TelegramCore#shared,iphoneos-armv7 \
//submodules/AsyncDisplayKit:AsyncDisplayKit#dwarf-and-dsym,shared,iphoneos-armv7 \
//submodules/AsyncDisplayKit:AsyncDisplayKit#shared,iphoneos-armv7 \
//submodules/Display:Display#dwarf-and-dsym,shared,iphoneos-armv7 \
//submodules/Display:Display#shared,iphoneos-armv7 \
//submodules/TelegramUI:TelegramUI#dwarf-and-dsym,shared,iphoneos-armv7 \
//submodules/TelegramUI:TelegramUI#shared,iphoneos-armv7 \
//Telegram:WatchAppExtension#dwarf-and-dsym,watchos-armv7_32,watchos-armv7k \
//Telegram:ShareExtension#dwarf-and-dsym,iphoneos-armv7 \
//Telegram:WidgetExtension#dwarf-and-dsym,iphoneos-armv7 \
//Telegram:NotificationContentExtension#dwarf-and-dsym,iphoneos-armv7 \
//Telegram:NotificationServiceExtension#dwarf-and-dsym,iphoneos-armv7 \
//Telegram:IntentsExtension#dwarf-and-dsym,iphoneos-armv7 \
${BUCK_OPTIONS} ${BUCK_DEBUG_OPTIONS} ${BUCK_THREADS_OPTIONS} ${BUCK_CACHE_OPTIONS}
build: check_env
$(BUCK) build \
//Telegram:AppPackage#iphoneos-arm64,iphoneos-armv7 \
//Telegram:Telegram#dwarf-and-dsym,iphoneos-arm64,iphoneos-armv7 \
//submodules/MtProtoKit:MtProtoKit#dwarf-and-dsym,shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/MtProtoKit:MtProtoKit#shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#dwarf-and-dsym,shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/Postbox:Postbox#dwarf-and-dsym,shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/Postbox:Postbox#shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/TelegramApi:TelegramApi#dwarf-and-dsym,shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/TelegramApi:TelegramApi#shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/SyncCore:SyncCore#dwarf-and-dsym,shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/SyncCore:SyncCore#shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/TelegramCore:TelegramCore#dwarf-and-dsym,shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/TelegramCore:TelegramCore#shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/AsyncDisplayKit:AsyncDisplayKit#dwarf-and-dsym,shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/AsyncDisplayKit:AsyncDisplayKit#shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/Display:Display#dwarf-and-dsym,shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/Display:Display#shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/TelegramUI:TelegramUI#dwarf-and-dsym,shared,iphoneos-arm64,iphoneos-armv7 \
//submodules/TelegramUI:TelegramUI#shared,iphoneos-arm64,iphoneos-armv7 \
//Telegram:WatchAppExtension#dwarf-and-dsym,watchos-arm64_32,watchos-armv7k \
//Telegram:ShareExtension#dwarf-and-dsym,iphoneos-arm64,iphoneos-armv7 \
//Telegram:WidgetExtension#dwarf-and-dsym,iphoneos-arm64,iphoneos-armv7 \
//Telegram:NotificationContentExtension#dwarf-and-dsym,iphoneos-arm64,iphoneos-armv7 \
//Telegram:NotificationServiceExtension#dwarf-and-dsym,iphoneos-arm64,iphoneos-armv7 \
//Telegram:IntentsExtension#dwarf-and-dsym,iphoneos-arm64,iphoneos-armv7 \
${BUCK_OPTIONS} ${BUCK_RELEASE_OPTIONS} ${BUCK_THREADS_OPTIONS} ${BUCK_CACHE_OPTIONS}
package_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="Telegram/${ENTITLEMENTS_APP}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Share="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_SHARE}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Share="Telegram/${ENTITLEMENTS_EXTENSION_SHARE}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Widget="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_WIDGET}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Widget="Telegram/${ENTITLEMENTS_EXTENSION_WIDGET}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_NotificationService="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONSERVICE}" \
PACKAGE_ENTITLEMENTS_EXTENSION_NotificationService="Telegram/${ENTITLEMENTS_EXTENSION_NOTIFICATIONSERVICE}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_NotificationContent="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONCONTENT}" \
PACKAGE_ENTITLEMENTS_EXTENSION_NotificationContent="Telegram/${ENTITLEMENTS_EXTENSION_NOTIFICATIONCONTENT}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Intents="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_INTENTS}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Intents="Telegram/${ENTITLEMENTS_EXTENSION_INTENTS}" \
PACKAGE_PROVISIONING_PROFILE_WATCH_APP="${DISTRIBUTION_PROVISIONING_PROFILE_WATCH_APP}" \
PACKAGE_PROVISIONING_PROFILE_WATCH_EXTENSION="${DISTRIBUTION_PROVISIONING_PROFILE_WATCH_EXTENSION}" \
PACKAGE_BUNDLE_ID="${BUNDLE_ID}" \
sh package_app.sh iphoneos-arm64 $(BUCK) "telegram" $(BUCK_OPTIONS) ${BUCK_RELEASE_OPTIONS}
package_armv7:
PACKAGE_DEVELOPMENT_TEAM="${DEVELOPMENT_TEAM}" \
PACKAGE_CODE_SIGN_IDENTITY="${DISTRIBUTION_CODE_SIGN_IDENTITY}" \
PACKAGE_PROVISIONING_PROFILE_APP="${DISTRIBUTION_PROVISIONING_PROFILE_APP}" \
PACKAGE_ENTITLEMENTS_APP="Telegram/${ENTITLEMENTS_APP}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Share="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_SHARE}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Share="Telegram/${ENTITLEMENTS_EXTENSION_SHARE}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Widget="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_WIDGET}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Widget="Telegram/${ENTITLEMENTS_EXTENSION_WIDGET}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_NotificationService="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONSERVICE}" \
PACKAGE_ENTITLEMENTS_EXTENSION_NotificationService="Telegram/${ENTITLEMENTS_EXTENSION_NOTIFICATIONSERVICE}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_NotificationContent="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONCONTENT}" \
PACKAGE_ENTITLEMENTS_EXTENSION_NotificationContent="Telegram/${ENTITLEMENTS_EXTENSION_NOTIFICATIONCONTENT}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Intents="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_INTENTS}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Intents="Telegram/${ENTITLEMENTS_EXTENSION_INTENTS}" \
PACKAGE_PROVISIONING_PROFILE_WATCH_APP="${DISTRIBUTION_PROVISIONING_PROFILE_WATCH_APP}" \
PACKAGE_PROVISIONING_PROFILE_WATCH_EXTENSION="${DISTRIBUTION_PROVISIONING_PROFILE_WATCH_EXTENSION}" \
PACKAGE_BUNDLE_ID="${BUNDLE_ID}" \
sh package_app.sh iphoneos-armv7 $(BUCK) "telegram" $(BUCK_OPTIONS) ${BUCK_RELEASE_OPTIONS}
package_debug_arm64:
PACKAGE_DEVELOPMENT_TEAM="${DEVELOPMENT_TEAM}" \
PACKAGE_CODE_SIGN_IDENTITY="${DEVELOPMENT_CODE_SIGN_IDENTITY}" \
PACKAGE_PROVISIONING_PROFILE_APP="${DEVELOPMENT_PROVISIONING_PROFILE_APP}" \
PACKAGE_ENTITLEMENTS_APP="Telegram/${ENTITLEMENTS_APP}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Share="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_SHARE}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Share="Telegram/${ENTITLEMENTS_EXTENSION_SHARE}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Widget="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_WIDGET}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Widget="Telegram/${ENTITLEMENTS_EXTENSION_WIDGET}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_NotificationService="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONSERVICE}" \
PACKAGE_ENTITLEMENTS_EXTENSION_NotificationService="Telegram/${ENTITLEMENTS_EXTENSION_NOTIFICATIONSERVICE}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_NotificationContent="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONCONTENT}" \
PACKAGE_ENTITLEMENTS_EXTENSION_NotificationContent="Telegram/${ENTITLEMENTS_EXTENSION_NOTIFICATIONCONTENT}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Intents="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_INTENTS}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Intents="Telegram/${ENTITLEMENTS_EXTENSION_INTENTS}" \
PACKAGE_PROVISIONING_PROFILE_WATCH_APP="${DEVELOPMENT_PROVISIONING_PROFILE_WATCH_APP}" \
PACKAGE_PROVISIONING_PROFILE_WATCH_EXTENSION="${DEVELOPMENT_PROVISIONING_PROFILE_WATCH_EXTENSION}" \
PACKAGE_BUNDLE_ID="${BUNDLE_ID}" \
ENABLE_GET_TASK_ALLOW=0 \
CODESIGNING_PROFILES_VARIANT="development" \
sh package_app.sh iphoneos-arm64 $(BUCK) "telegram" $(BUCK_OPTIONS) ${BUCK_RELEASE_OPTIONS}
package_debug_armv7:
PACKAGE_DEVELOPMENT_TEAM="${DEVELOPMENT_TEAM}" \
PACKAGE_CODE_SIGN_IDENTITY="${DEVELOPMENT_CODE_SIGN_IDENTITY}" \
PACKAGE_PROVISIONING_PROFILE_APP="${DEVELOPMENT_PROVISIONING_PROFILE_APP}" \
PACKAGE_ENTITLEMENTS_APP="Telegram/${ENTITLEMENTS_APP}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Share="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_SHARE}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Share="Telegram/${ENTITLEMENTS_EXTENSION_SHARE}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Widget="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_WIDGET}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Widget="Telegram/${ENTITLEMENTS_EXTENSION_WIDGET}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_NotificationService="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONSERVICE}" \
PACKAGE_ENTITLEMENTS_EXTENSION_NotificationService="Telegram/${ENTITLEMENTS_EXTENSION_NOTIFICATIONSERVICE}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_NotificationContent="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONCONTENT}" \
PACKAGE_ENTITLEMENTS_EXTENSION_NotificationContent="Telegram/${ENTITLEMENTS_EXTENSION_NOTIFICATIONCONTENT}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Intents="${DEVELOPMENT_PROVISIONING_PROFILE_EXTENSION_INTENTS}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Intents="Telegram/${ENTITLEMENTS_EXTENSION_INTENTS}" \
PACKAGE_PROVISIONING_PROFILE_WATCH_APP="${DEVELOPMENT_PROVISIONING_PROFILE_WATCH_APP}" \
PACKAGE_PROVISIONING_PROFILE_WATCH_EXTENSION="${DEVELOPMENT_PROVISIONING_PROFILE_WATCH_EXTENSION}" \
PACKAGE_BUNDLE_ID="${BUNDLE_ID}" \
ENABLE_GET_TASK_ALLOW=0 \
CODESIGNING_PROFILES_VARIANT="development" \
sh package_app.sh iphoneos-armv7 $(BUCK) "telegram" $(BUCK_OPTIONS) ${BUCK_RELEASE_OPTIONS}
package:
PACKAGE_DEVELOPMENT_TEAM="${DEVELOPMENT_TEAM}" \
PACKAGE_CODE_SIGN_IDENTITY="${DISTRIBUTION_CODE_SIGN_IDENTITY}" \
PACKAGE_PROVISIONING_PROFILE_APP="${DISTRIBUTION_PROVISIONING_PROFILE_APP}" \
PACKAGE_ENTITLEMENTS_APP="Telegram/${ENTITLEMENTS_APP}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Share="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_SHARE}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Share="Telegram/${ENTITLEMENTS_EXTENSION_SHARE}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Widget="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_WIDGET}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Widget="Telegram/${ENTITLEMENTS_EXTENSION_WIDGET}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_NotificationService="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONSERVICE}" \
PACKAGE_ENTITLEMENTS_EXTENSION_NotificationService="Telegram/${ENTITLEMENTS_EXTENSION_NOTIFICATIONSERVICE}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_NotificationContent="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_NOTIFICATIONCONTENT}" \
PACKAGE_ENTITLEMENTS_EXTENSION_NotificationContent="Telegram/${ENTITLEMENTS_EXTENSION_NOTIFICATIONCONTENT}" \
PACKAGE_PROVISIONING_PROFILE_EXTENSION_Intents="${DISTRIBUTION_PROVISIONING_PROFILE_EXTENSION_INTENTS}" \
PACKAGE_ENTITLEMENTS_EXTENSION_Intents="Telegram/${ENTITLEMENTS_EXTENSION_INTENTS}" \
PACKAGE_PROVISIONING_PROFILE_WATCH_APP="${DISTRIBUTION_PROVISIONING_PROFILE_WATCH_APP}" \
PACKAGE_PROVISIONING_PROFILE_WATCH_EXTENSION="${DISTRIBUTION_PROVISIONING_PROFILE_WATCH_EXTENSION}" \
PACKAGE_BUNDLE_ID="${BUNDLE_ID}" \
sh package_app.sh iphoneos-arm64,iphoneos-armv7 $(BUCK) "telegram" $(BUCK_OPTIONS) ${BUCK_RELEASE_OPTIONS}
app: build package
app_arm64: build_arm64 package_arm64
app_debug_arm64: build_debug_arm64 package_debug_arm64
wallet_debug_arm64: build_wallet_debug_arm64
app_debug_armv7: build_debug_armv7 package_debug_armv7
build_buckdebug: check_env
BUCK_DEBUG_MODE=1 $(BUCK) build \
//Telegram:AppPackage#iphoneos-arm64 \
//Telegram:Telegram#dwarf-and-dsym,iphoneos-arm64 \
//submodules/MtProtoKit:MtProtoKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/MtProtoKit:MtProtoKit#shared,iphoneos-arm64 \
//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#shared,iphoneos-arm64 \
//submodules/Postbox:Postbox#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/Postbox:Postbox#shared,iphoneos-arm64 \
//submodules/TelegramApi:TelegramApi#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/TelegramApi:TelegramApi#shared,iphoneos-arm64 \
//submodules/SyncCore:SyncCore#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/SyncCore:SyncCore#shared,iphoneos-arm64 \
//submodules/TelegramCore:TelegramCore#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/TelegramCore:TelegramCore#shared,iphoneos-arm64 \
//submodules/AsyncDisplayKit:AsyncDisplayKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/AsyncDisplayKit:AsyncDisplayKit#shared,iphoneos-arm64 \
//submodules/Display:Display#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/Display:Display#shared,iphoneos-arm64 \
//submodules/TelegramUI:TelegramUI#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/TelegramUI:TelegramUI#shared,iphoneos-arm64 \
//Telegram:WatchAppExtension#dwarf-and-dsym,watchos-arm64_32,watchos-armv7k \
//Telegram:ShareExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:WidgetExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:NotificationContentExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:NotificationServiceExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:IntentsExtension#dwarf-and-dsym,iphoneos-arm64 \
--verbose 7 ${BUCK_OPTIONS} ${BUCK_DEBUG_OPTIONS}
build_verbose: check_env
$(BUCK) build \
//Telegram:AppPackage#iphoneos-arm64 \
//Telegram:Telegram#dwarf-and-dsym,iphoneos-arm64 \
//submodules/MtProtoKit:MtProtoKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/MtProtoKit:MtProtoKit#shared,iphoneos-arm64 \
//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#shared,iphoneos-arm64 \
//submodules/Postbox:Postbox#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/Postbox:Postbox#shared,iphoneos-arm64 \
//submodules/TelegramApi:TelegramApi#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/TelegramApi:TelegramApi#shared,iphoneos-arm64 \
//submodules/SyncCore:SyncCore#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/SyncCore:SyncCore#shared,iphoneos-arm64 \
//submodules/TelegramCore:TelegramCore#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/TelegramCore:TelegramCore#shared,iphoneos-arm64 \
//submodules/AsyncDisplayKit:AsyncDisplayKit#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/AsyncDisplayKit:AsyncDisplayKit#shared,iphoneos-arm64 \
//submodules/Display:Display#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/Display:Display#shared,iphoneos-arm64 \
//submodules/TelegramUI:TelegramUI#dwarf-and-dsym,shared,iphoneos-arm64 \
//submodules/TelegramUI:TelegramUI#shared,iphoneos-arm64 \
//Telegram:WatchAppExtension#dwarf-and-dsym,watchos-arm64_32,watchos-armv7k \
//Telegram:ShareExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:WidgetExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:NotificationContentExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:NotificationServiceExtension#dwarf-and-dsym,iphoneos-arm64 \
//Telegram:IntentsExtension#dwarf-and-dsym,iphoneos-arm64 \
--verbose 7 ${BUCK_OPTIONS} ${BUCK_THREADS_OPTIONS} ${BUCK_DEBUG_OPTIONS} ${BUCK_CACHE_OPTIONS}
deps: check_env
$(BUCK) query "deps(//Telegram:AppPackage)" --dot \
${BUCK_OPTIONS} ${BUCK_DEBUG_OPTIONS}
clean: kill_xcode
sh clean.sh
project: check_env kill_xcode
$(BUCK) project //Telegram:workspace --config custom.mode=project ${BUCK_OPTIONS} ${BUCK_DEBUG_OPTIONS}
open Telegram/Telegram_Buck.xcworkspace
bazel_app_debug_arm64:
APP_VERSION="${APP_VERSION}" \
TELEGRAM_DISABLE_EXTENSIONS="0" \
build-system/prepare-build.sh Telegram distribution
"${BAZEL}" build Telegram/Telegram ${BAZEL_CACHE_FLAGS} ${BAZEL_COMMON_FLAGS} ${BAZEL_DEBUG_FLAGS} \
-c dbg \
--ios_multi_cpus=arm64 \
--watchos_cpus=armv7k,arm64_32 \
--verbose_failures
bazel_app_arm64:
APP_VERSION="${APP_VERSION}" \
BAZEL_CACHE_DIR="${BAZEL_CACHE_DIR}" \
BAZEL_HTTP_CACHE_URL="${BAZEL_HTTP_CACHE_URL}" \
TELEGRAM_DISABLE_EXTENSIONS="0" \
build-system/prepare-build.sh Telegram distribution
"${BAZEL}" build Telegram/Telegram ${BAZEL_CACHE_FLAGS} ${BAZEL_COMMON_FLAGS} ${BAZEL_OPT_FLAGS} \
-c opt \
--ios_multi_cpus=arm64 \
--watchos_cpus=armv7k,arm64_32 \
--apple_generate_dsym \
--output_groups=+dsyms \
--verbose_failures
bazel_app_armv7:
APP_VERSION="${APP_VERSION}" \
BAZEL_CACHE_DIR="${BAZEL_CACHE_DIR}" \
BAZEL_HTTP_CACHE_URL="${BAZEL_HTTP_CACHE_URL}" \
TELEGRAM_DISABLE_EXTENSIONS="0" \
build-system/prepare-build.sh Telegram distribution
"${BAZEL}" build Telegram/Telegram ${BAZEL_CACHE_FLAGS} ${BAZEL_COMMON_FLAGS} ${BAZEL_OPT_FLAGS} \
-c opt \
--ios_multi_cpus=armv7 \
--watchos_cpus=armv7k,arm64_32 \
--apple_generate_dsym \
--output_groups=+dsyms \
--verbose_failures
bazel_app:
APP_VERSION="${APP_VERSION}" \
BAZEL_CACHE_DIR="${BAZEL_CACHE_DIR}" \
BAZEL_HTTP_CACHE_URL="${BAZEL_HTTP_CACHE_URL}" \
TELEGRAM_DISABLE_EXTENSIONS="0" \
build-system/prepare-build.sh Telegram distribution
"${BAZEL}" build Telegram/Telegram ${BAZEL_CACHE_FLAGS} ${BAZEL_COMMON_FLAGS} ${BAZEL_OPT_FLAGS} \
-c opt \
--ios_multi_cpus=armv7,arm64 \
--watchos_cpus=armv7k,arm64_32 \
--apple_generate_dsym \
--output_groups=+dsyms \
--verbose_failures
bazel_project: kill_xcode
APP_VERSION="${APP_VERSION}" \
BAZEL_CACHE_DIR="${BAZEL_CACHE_DIR}" \
BAZEL_HTTP_CACHE_URL="${BAZEL_HTTP_CACHE_URL}" \
TELEGRAM_DISABLE_EXTENSIONS="0" \
build-system/prepare-build.sh Telegram development
APP_VERSION="${APP_VERSION}" \
BAZEL_CACHE_DIR="${BAZEL_CACHE_DIR}" \
BAZEL_HTTP_CACHE_URL="${BAZEL_HTTP_CACHE_URL}" \
build-system/generate-xcode-project.sh Telegram
bazel_project_noextensions: kill_xcode
APP_VERSION="${APP_VERSION}" \
BAZEL_CACHE_DIR="${BAZEL_CACHE_DIR}" \
BAZEL_HTTP_CACHE_URL="${BAZEL_HTTP_CACHE_URL}" \
TELEGRAM_DISABLE_EXTENSIONS="1" \
build-system/prepare-build.sh Telegram development
APP_VERSION="${APP_VERSION}" \
BAZEL_CACHE_DIR="${BAZEL_CACHE_DIR}" \
BAZEL_HTTP_CACHE_URL="${BAZEL_HTTP_CACHE_URL}" \
build-system/generate-xcode-project.sh Telegram

View File

@ -1,6 +1,6 @@
# Telegram iOS Source Code Compilation Guide
1. Install Xcode (directly from https://developer.apple.com/download/more or using App Store).
1. Install Xcode (directly from https://developer.apple.com/download/more or using the App Store).
2. Clone the project from GitHub:
```
@ -67,7 +67,7 @@ Tip: use `--disableExtensions` when developing to speed up development by not bu
# Tips
Bazel is used to build the app. In order to simplify the development setup a helper script is provided (`build-system/Make/Make.py`). See help:
Bazel is used to build the app. To simplify the development setup a helper script is provided (`build-system/Make/Make.py`). See help:
```
python3 build-system/Make/Make.py --help
@ -75,7 +75,7 @@ python3 build-system/Make/Make.py build --help
python3 build-system/Make/Make.py generateProject --help
```
Each release is built using specific Xcode and Bazel versions (see `versions.json`). The helper script checks the versions of installed software and reports an error if they don't match the ones specified in `versions.json`. There is flag that allows to bypass these checks:
Each release is built using specific Xcode and Bazel versions (see `versions.json`). The helper script checks the versions of installed software and reports an error if they don't match the ones specified in `versions.json`. There are flags that allow to bypass these checks:
```
python3 build-system/Make/Make.py --overrideBazelVersion build ... # Don't check the version of Bazel

View File

@ -1,37 +0,0 @@
export BUCK_DEBUG_OPTIONS=\
--config custom.other_cflags="-O0 -D DEBUG" \
--config custom.other_cxxflags="-O0 -D DEBUG" \
--config custom.optimization="-Onone" \
--config custom.config_swift_compiler_flags="-DDEBUG"
export BUCK_RELEASE_OPTIONS=\
--config custom.other_cflags="-Os" \
--config custom.other_cxxflags="-Os" \
--config custom.optimization="-Osize" \
--config custom.config_swift_compiler_flags="-whole-module-optimization"
export BUCK_THREADS_OPTIONS=--config build.threads=$(shell sysctl -n hw.logicalcpu)
ifneq ($(BUCK_HTTP_CACHE),)
ifeq ($(BUCK_CACHE_MODE),)
BUCK_CACHE_MODE=readwrite
endif
export BUCK_CACHE_OPTIONS=\
--config cache.mode=http \
--config cache.http_url="$(BUCK_HTTP_CACHE)" \
--config cache.http_mode="$(BUCK_CACHE_MODE)"
endif
ifneq ($(BUCK_DIR_CACHE),)
export BUCK_CACHE_OPTIONS=\
--config cache.mode=dir \
--config cache.dir="$(BUCK_DIR_CACHE)" \
--config cache.dir_mode="readwrite"
endif
check_env:
sh check_env.sh
kill_xcode:
killall Xcode || true

View File

@ -1,6 +0,0 @@
#!/bin/bash
if [ -z "$TELEGRAM_ENV_SET" ]; then
echo "Error: Telegram build environment is not set up. Use sh public.sh make ${command}"
exit 1
fi

View File

@ -1,4 +0,0 @@
rm -rf App/App.xcodeproj App/App.xcworkspace
rm -rf submodules/MtProtoKit/MtProtoKit.xcodeproj
rm -rf submodules/Emoji/Emoji.xcodeproj
rm -rf buck-out

View File

@ -1,94 +0,0 @@
import sys
import os
import re
import shutil
ignore_patterns_when_copying = [
"^\\.git$",
"^.*/\\.git$",
]
def mkdir_p(path):
if not os.path.isdir(path):
os.makedirs(path)
def clean_copy_files(dir, destination_dir):
for root, dirs, files in os.walk(dir, topdown=False):
for name in files:
skip_file = False
for pattern in ignore_patterns_when_copying:
if re.match(pattern, name):
skip_file = True
break
if skip_file:
continue
file_path = os.path.relpath(os.path.join(root, name), dir)
dir_path = os.path.dirname(file_path)
mkdir_p(destination_dir + "/" + dir_path)
shutil.copy(dir + "/" + file_path, destination_dir + "/" + file_path)
for name in dirs:
skip_file = False
for pattern in ignore_patterns_when_copying:
if re.match(pattern, name):
skip_file = True
break
if skip_file:
continue
dir_path = os.path.relpath(os.path.join(root, name), dir)
if os.path.islink(dir + "/" + dir_path):
continue
mkdir_p(destination_dir + "/" + dir_path)
if len(sys.argv) != 2:
print('Usage: extract_wallet_source.py destination')
sys.exit(1)
destination = sys.argv[1]
deps_data = os.popen("""bazel query 'kind("source file", deps(//Wallet:Wallet))'""").read().splitlines()
buildfile_deps_data = os.popen("""bazel query 'buildfiles(deps(//Wallet:Wallet))'""").read().splitlines()
directories = set()
for line in deps_data + buildfile_deps_data:
if len(line) == 0:
continue
if line[:1] == "@":
continue
if line[:2] != "//":
continue
file_path = line[2:].replace(":", "/")
if file_path.startswith("build-input"):
continue
if file_path.startswith("external"):
continue
file_name = os.path.basename(file_path)
file_dir = os.path.dirname(file_path)
mkdir_p(destination + "/" + file_dir)
shutil.copy(file_path, destination + '/' + file_path)
additional_paths = [
".gitignore",
"WORKSPACE",
"build-system/xcode_version",
"build-system/bazel_version",
"build-system/bazel-rules",
"build-system/tulsi",
"build-system/prepare-build.sh",
"build-system/generate-xcode-project.sh",
"build-system/copy-provisioning-profiles-Wallet.sh",
"build-system/prepare-build-variables-Wallet.sh",
".bazelrc",
"wallet_env.sh",
]
for file_path in additional_paths:
if os.path.isdir(file_path):
clean_copy_files(file_path, destination + "/" + file_path)
else:
shutil.copy(file_path, destination + "/" + file_path)
shutil.copy("Wallet.makefile", destination + "/" + "Makefile")
shutil.copy("Wallet/README.md", destination + "/" + "README.md")

View File

@ -1,522 +0,0 @@
#!/bin/sh
set -e
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo "Usage: sh package_app.sh path/to/buck platform-flavors type"
exit 1
fi
PLATFORM_FLAVORS="$1"
BUCK="$2"
APP_TYPE="$3"
shift
shift
shift
BUILD_PATH="build"
if [ "$APP_TYPE" == "wallet" ]; then
APP_NAME="TONWallet"
else
APP_NAME="Telegram"
fi
IPA_PATH="$BUILD_PATH/$APP_NAME.ipa"
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"
KEYCHAIN_PATH="$TEMP_PATH/keychain"
if [ -z "$PACKAGE_BUNDLE_ID" ]; then
echo "PACKAGE_BUNDLE_ID not set"
exit 1
fi
BUNDLE_ID_PREFIX=$(echo "$PACKAGE_BUNDLE_ID" | grep -Eo "^.*?\\..*?\\." | head -1)
if [ -z "$BUNDLE_ID_PREFIX" ]; then
echo "Could not extract bundle id prefix from $PACKAGE_BUNDLE_ID"
exit 1
fi
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"
if [ "$APP_TYPE" == "wallet" ]; then
cp "buck-out/gen/Wallet/AppPackage#$PLATFORM_FLAVORS.ipa" "$IPA_PATH.original"
else
cp "buck-out/gen/Telegram/AppPackage#$PLATFORM_FLAVORS.ipa" "$IPA_PATH.original"
fi
rm -rf "$IPA_PATH.original.unpacked"
rm -f "$BUILD_PATH/${APP_NAME}_signed.ipa"
mkdir -p "$IPA_PATH.original.unpacked"
echo "Unzipping original ipa..."
unzip "$IPA_PATH.original" -d "$IPA_PATH.original.unpacked/" 1>/dev/null
rm "$IPA_PATH.original"
UNPACKED_PATH="$IPA_PATH.original.unpacked"
if [ "$APP_TYPE" == "wallet" ]; then
APP_PATH="$UNPACKED_PATH/Payload/Wallet.app"
else
APP_PATH="$UNPACKED_PATH/Payload/Telegram.app"
fi
FRAMEWORKS_DIR="$APP_PATH/Frameworks"
rm -rf "$IPA_PATH.original.unpacked/SwiftSupport/iphoneos/"*
rm -rf "$IPA_PATH.original.unpacked/Symbols/"*
rm -rf "$FRAMEWORKS_DIR/"*
if [ -z "$PACKAGE_METHOD" ]; then
echo "PACKAGE_METHOD is not set"
exit 1
fi
if [ "$PACKAGE_METHOD" != "appstore" ] && [ "$PACKAGE_METHOD" != "enterprise" ]; then
echo "PACKAGE_METHOD $PACKAGE_METHOD should be in [appstore, enterprise]"
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
if [ -z "$CODESIGNING_CERTS_VARIANT" ]; then
echo "CODESIGNING_CERTS_VARIANT is not set"
exit 1
fi
if [ -z "$CODESIGNING_PROFILES_VARIANT" ]; then
echo "CODESIGNING_PROFILES_VARIANT is not set"
exit 1
fi
CERTS_PATH="$CODESIGNING_DATA_PATH/certs/$CODESIGNING_CERTS_VARIANT"
PROFILES_PATH="$CODESIGNING_DATA_PATH/profiles/$CODESIGNING_PROFILES_VARIANT"
if [ ! -d "$CERTS_PATH" ]; then
echo "$CERTS_PATH does not exist"
exit 1
fi
if [ ! -d "$PROFILES_PATH" ]; then
echo "$PROFILES_PATH does not exist"
exit 1
fi
rm -f "$KEYCHAIN_PATH"
if [ "$APP_TYPE" == "wallet" ]; then
APP_ITEMS_WITH_PROVISIONING_PROFILE="APP"
APP_ITEMS_WITH_ENTITLEMENTS="APP"
else
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"
fi
COMMON_IDENTITY_HASH=""
REMOVE_ENTITLEMENT_KEYS=(\
"com.apple.developer.icloud-container-development-container-identifiers" \
"com.apple.developer.ubiquity-kvstore-identifier" \
)
COPY_ENTITLEMENT_KEYS=(\
"com.apple.developer.associated-domains" \
"com.apple.developer.icloud-services" \
"com.apple.developer.pushkit.unrestricted-voip" \
)
REPLACE_TO_PRODUCTION_ENTITLEMENT_KEYS=(\
"com.apple.developer.icloud-container-environment" \
)
echo "Generating entitlements..."
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 "$PROFILES_PATH/"*; 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
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"
for KEY in "${REMOVE_ENTITLEMENT_KEYS[@]}"; do
/usr/libexec/PlistBuddy -c "Delete $KEY" "$PROFILE_ENTITLEMENTS_PATH" 2>/dev/null || true
done
for KEY in "${REPLACE_TO_PRODUCTION_ENTITLEMENT_KEYS[@]}"; do
VALUE=$(/usr/libexec/PlistBuddy -c "Print :$KEY" "$PROFILE_ENTITLEMENTS_PATH" 2>/dev/null || echo "")
if [ ! -z "$VALUE" ]; then
PLUTIL_KEY=$(echo "$KEY" | sed 's/\./\\\./g')
/usr/libexec/PlistBuddy -c "Delete $KEY" "$PROFILE_ENTITLEMENTS_PATH" 2>/dev/null
VALUE="<array><string>Production</string></array>"
plutil -insert "$PLUTIL_KEY" -xml "$VALUE" "$PROFILE_ENTITLEMENTS_PATH"
fi
done
if [ "$ENABLE_GET_TASK_ALLOW" == "1" ]; then
KEY="com.apple.security.get-task-allow"
PLUTIL_KEY=$(echo "$KEY" | sed 's/\./\\\./g')
plutil -insert "$PLUTIL_KEY" -xml "<true/>" "$PROFILE_ENTITLEMENTS_PATH"
fi
ENTITLEMENTS_VAR=PACKAGE_ENTITLEMENTS_$ITEM
if [ ! -z "${!ENTITLEMENTS_VAR}" ]; then
if [ ! -f "${!ENTITLEMENTS_VAR}" ]; then
echo "${!ENTITLEMENTS_VAR} does not exist"
exit 1
fi
for KEY in "${COPY_ENTITLEMENT_KEYS[@]}"; do
VALUE=$(/usr/libexec/PlistBuddy -c "Print :$KEY" "$PROFILE_ENTITLEMENTS_PATH" 2>/dev/null || echo "")
if [ ! -z "$VALUE" ]; then
PLUTIL_KEY=$(echo "$KEY" | sed 's/\./\\\./g')
TEST_VALUE=$(plutil -extract "$PLUTIL_KEY" xml1 -o - "${!ENTITLEMENTS_VAR}" 1>/dev/null || echo "error")
if [ "$TEST_VALUE" != "error" ]; then
VALUE=$(plutil -extract "$PLUTIL_KEY" xml1 -o - "${!ENTITLEMENTS_VAR}")
/usr/libexec/PlistBuddy -c "Delete $KEY" "$PROFILE_ENTITLEMENTS_PATH" 2>/dev/null
plutil -insert "$PLUTIL_KEY" -xml "$VALUE" "$PROFILE_ENTITLEMENTS_PATH"
fi
fi
done
fi
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
done
if [ -z "$COMMON_IDENTITY_HASH" ]; then
echo "Failed to determine signing identity"
exit 1
fi
COPY_PLIST_KEYS=(\
"DTSDKName" \
"DTXcode" \
"DTSDKBuild" \
"CFBundleDevelopmentRegion" \
"BuildMachineOSBuild" \
"DTPlatformName" \
"CFBundleSupportedPlatforms" \
"CFBundleInfoDictionaryVersion" \
"DTCompiler" \
"MinimumOSVersion" \
"UIDeviceFamily" \
"DTPlatformVersion" \
"DTXcodeBuild" \
"DTPlatformBuild" \
)
APP_PLIST="$APP_PATH/Info.plist"
if [ "$APP_TYPE" == "wallet" ]; then
APP_BINARY_TARGET="//Wallet:Wallet"
else
APP_BINARY_TARGET="//Telegram:Telegram"
fi
echo "Repacking frameworks..."
for DEPENDENCY in $(${BUCK} query "kind('apple_library', deps('${APP_BINARY_TARGET}#$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"
mkdir -p "$FRAMEWORKS_DIR/${DEPENDENCY_NAME}.framework"
TARGET_DYLIB_PATH="$FRAMEWORKS_DIR/${DEPENDENCY_NAME}.framework/$DEPENDENCY_NAME"
PLIST_FILE="$FRAMEWORKS_DIR/${DEPENDENCY_NAME}.framework/Info.plist"
/usr/libexec/PlistBuddy -c "Add :CFBundleName string \"${DEPENDENCY_NAME}\"" "$PLIST_FILE" 1>/dev/null
/usr/libexec/PlistBuddy -c "Add :CFBundleVersion string \"1\"" "$PLIST_FILE"
/usr/libexec/PlistBuddy -c "Add :CFBundleShortVersionString string \"1.0\"" "$PLIST_FILE"
/usr/libexec/PlistBuddy -c "Add :CFBundlePackageType string \"FMWK\"" "$PLIST_FILE"
/usr/libexec/PlistBuddy -c "Add :CFBundleExecutable string \"${DEPENDENCY_NAME}\"" "$PLIST_FILE"
/usr/libexec/PlistBuddy -c "Add :CFBundleIdentifier string \"${BUNDLE_ID_PREFIX}.${DEPENDENCY_NAME}\"" "$PLIST_FILE"
for KEY in "${COPY_PLIST_KEYS[@]}"; do
VALUE=$(/usr/libexec/PlistBuddy -c "Print :$KEY" "$APP_PLIST" 2>/dev/null || echo "")
if [ ! -z "$VALUE" ]; then
PLUTIL_KEY=$(echo "$KEY" | sed 's/\./\\\./g')
VALUE=$(plutil -extract "$PLUTIL_KEY" xml1 -o - "$APP_PLIST")
plutil -insert "$PLUTIL_KEY" -xml "$VALUE" "$PLIST_FILE"
fi
done
plutil -convert binary1 "$PLIST_FILE"
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 -r "$DSYM_PATH" "$DSYMS_DIR/"
done
if [ "$APP_TYPE" == "wallet" ]; then
APP_BINARY_DSYM_PATH="buck-out/gen/Wallet/Wallet#dwarf-and-dsym,$PLATFORM_FLAVORS,no-include-frameworks/Wallet.app.dSYM"
else
APP_BINARY_DSYM_PATH="buck-out/gen/Telegram/Telegram#dwarf-and-dsym,$PLATFORM_FLAVORS,no-include-frameworks/Telegram.app.dSYM"
fi
cp -r "$APP_BINARY_DSYM_PATH" "$DSYMS_DIR/"
if [ "$APP_TYPE" == "wallet" ]; then
EXTENSIONS=""
else
EXTENSIONS="Share Widget Intents NotificationContent NotificationService"
fi
for EXTENSION in $EXTENSIONS; do
EXTENSION_DSYM_PATH="buck-out/gen/Telegram/${EXTENSION}Extension#dwarf-and-dsym,$PLATFORM_FLAVORS,no-include-frameworks/${EXTENSION}Extension.appex.dSYM"
cp -r "$EXTENSION_DSYM_PATH" "$DSYMS_DIR/"
done
if [ "$APP_TYPE" != "wallet" ]; then
WATCH_EXTENSION_DSYM_PATH="buck-out/gen/Telegram/WatchAppExtension#dwarf-and-dsym,no-include-frameworks,watchos-arm64_32,watchos-armv7k/WatchAppExtension.appex.dSYM"
cp -r "$WATCH_EXTENSION_DSYM_PATH" "$DSYMS_DIR/"
fi
TEMP_DYLIB_DIR="$TEMP_PATH/SwiftSupport"
rm -rf "$TEMP_DYLIB_DIR"
mkdir -p "$TEMP_DYLIB_DIR"
mkdir -p "$TEMP_DYLIB_DIR/out"
if [ "$APP_TYPE" == "wallet" ]; then
EXECUTABLE_NAME="Wallet"
else
EXECUTABLE_NAME="Telegram"
fi
XCODE_PATH="$(xcode-select -p)"
TOOLCHAIN_PATH="$XCODE_PATH/Toolchains/XcodeDefault.xctoolchain"
if [ -f "$TOOLCHAIN_PATH/usr/lib/swift/iphoneos/libswiftCore.dylib" ]; then
SOURCE_LIBRARIES_PATH="$TOOLCHAIN_PATH/usr/lib/swift/iphoneos"
else
SOURCE_LIBRARIES_PATH="$TOOLCHAIN_PATH/usr/lib/swift-5.0/iphoneos"
fi
echo "Copying swift support files..."
xcrun swift-stdlib-tool \
--copy \
--strip-bitcode \
--platform iphoneos \
--toolchain "$TOOLCHAIN_PATH" \
--source-libraries "$SOURCE_LIBRARIES_PATH" \
--scan-executable "$APP_PATH/$EXECUTABLE_NAME" \
--scan-folder "$APP_PATH/Frameworks" \
--scan-folder "$APP_PATH/PlugIns" \
--destination "$TEMP_DYLIB_DIR"
for dylib in "$TEMP_DYLIB_DIR"/*.dylib; do
FILE_NAME=$(basename "$dylib")
lipo -extract armv7 "$dylib" -output "$dylib.armv7"
lipo -extract arm64 "$dylib" -output "$dylib.arm64"
lipo "$dylib.armv7" "$dylib.arm64" -create -output "$dylib.unstripped"
if [ "$PACKAGE_METHOD" == "enterprise" ]; then
xcrun strip -ST -o "$TEMP_DYLIB_DIR/out/$FILE_NAME" - "$dylib.unstripped" 2>/dev/null
xcrun bitcode_strip -r "$TEMP_DYLIB_DIR/out/$FILE_NAME" -o "$TEMP_DYLIB_DIR/out/$FILE_NAME" 1>/dev/null
else
cp "$dylib.unstripped" "$TEMP_DYLIB_DIR/out/$FILE_NAME"
fi
done
cp "$TEMP_DYLIB_DIR/out/"*.dylib "$IPA_PATH.original.unpacked/SwiftSupport/iphoneos/"
cp "$IPA_PATH.original.unpacked/SwiftSupport/iphoneos/"*.dylib "$FRAMEWORKS_DIR/"
REMOVE_ARCHS="armv7s arm64e"
for framework in "$FRAMEWORKS_DIR"/*; do
if [[ "$framework" == *.framework || "$framework" == *.dylib ]]; then
if [[ "$framework" == *.framework ]]; then
FRAMEWORK_NAME=$(basename "$framework" | sed -e 's/\.framework//')
for ARCH in $REMOVE_ARCHS; do
lipo -remove "$ARCH" "$framework/$FRAMEWORK_NAME" -o "$framework/$FRAMEWORK_NAME" 2>/dev/null || true
done
xcrun bitcode_strip -r "$framework/$FRAMEWORK_NAME" -o "$framework/$FRAMEWORK_NAME" 1>/dev/null
xcrun strip -S -T -x "$framework/$FRAMEWORK_NAME" 1>/dev/null
/usr/bin/codesign ${VERBOSE} ${KEYCHAIN_FLAG} -f -s "$COMMON_IDENTITY_HASH" "$framework" 1>/dev/null
else
/usr/bin/codesign ${VERBOSE} ${KEYCHAIN_FLAG} -f -s "$COMMON_IDENTITY_HASH" "$framework" 1>/dev/null
fi
fi
done
echo "Signing..."
if [ "$APP_TYPE" == "wallet" ]; then
PLUGINS=""
else
PLUGINS="Share Widget Intents NotificationService NotificationContent"
fi
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
if [ "$APP_TYPE" != "wallet" ]; then
WATCH_APP_PATH="$APP_PATH/Watch/WatchApp.app"
WATCH_EXTENSION_PATH="$WATCH_APP_PATH/PlugIns/WatchAppExtension.appex"
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" 2>/dev/null
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" 2>/dev/null
fi
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"
if [ "$PACKAGE_METHOD" == "appstore" ]; then
zip -r "../${APP_NAME}_signed.ipa" Payload SwiftSupport WatchKitSupport2 1>/dev/null
elif [ "$PACKAGE_METHOD" == "enterprise" ]; then
zip -r "../${APP_NAME}_signed.ipa" Payload 1>/dev/null
fi
cd "$DIR"
cd "$BUILD_PATH"
zip -r "$DSYMS_FOLDER_NAME.zip" "$DSYMS_FOLDER_NAME" 1>/dev/null
cd "$DIR"
echo "Done"