Skip to content

Commit 0e3f0fe

Browse files
Fix .xcstickers app icon regression (#2831)
Regressed in d240302. Signed-off-by: Brentley Jones <github@brentleyjones.com>
1 parent b5d9c0d commit 0e3f0fe

3 files changed

Lines changed: 61 additions & 8 deletions

File tree

apple/internal/bundling_support.bzl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ def _ensure_asset_catalog_files_not_in_xcassets(
256256
*,
257257
extension,
258258
files,
259-
message = None):
259+
message = None,
260+
xcassets_extension = "xcassets"):
260261
"""Validates that a subset of asset catalog files are not within an xcassets directory.
261262
262263
Args:
@@ -265,19 +266,22 @@ def _ensure_asset_catalog_files_not_in_xcassets(
265266
files: An iterable of files to use.
266267
message: A custom error message to use, the list of found files that were found in xcassets
267268
directories will be printed afterwards.
269+
xcassets_extension: The extension of the xcassets directory. Normally `xcassets`, but other
270+
variations exist (e.g. `xcstickers`).
268271
"""
269272
_ensure_path_format(
270273
files = files,
271274
allowed_path_fragments = [],
272-
denied_path_fragments = ["xcassets", extension],
275+
denied_path_fragments = [xcassets_extension, extension],
273276
message = message,
274277
)
275278

276279
def _ensure_single_xcassets_type(
277280
*,
278281
extension,
279282
files,
280-
message = None):
283+
message = None,
284+
xcassets_extension = "xcassets"):
281285
"""Validates that asset catalog files are nested within an xcassets directory.
282286
283287
Args:
@@ -286,13 +290,15 @@ def _ensure_single_xcassets_type(
286290
files: An iterable of files to use.
287291
message: A custom error message to use, the list of found files that
288292
didn't match will be printed afterwards.
293+
xcassets_extension: The extension of the xcassets directory. Normally `xcassets`, but other
294+
variations exist (e.g. `xcstickers`).
289295
"""
290296
if not message:
291-
message = ("Expected the xcassets directory to only contain files " +
292-
"are in sub-directories with the extension %s") % extension
297+
message = ("Expected the %s directory to only contain files " +
298+
"are in sub-directories with the extension %s") % (xcassets_extension, extension)
293299
_ensure_path_format(
294300
files = files,
295-
allowed_path_fragments = ["xcassets", extension],
301+
allowed_path_fragments = [xcassets_extension, extension],
296302
denied_path_fragments = [],
297303
message = message,
298304
)

apple/internal/partials/app_assets_validation.bzl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ _STANDARD_ICONS = [".appiconset/", ".icon/"]
3030
# of platform.
3131
_VALID_ICON_EXTENSIONS_FOR_PRODUCT_TYPE = {
3232
apple_product_type.messages_extension: [".stickersiconset/"],
33-
apple_product_type.messages_sticker_pack_extension: [".stickersiconset/", ".stickerpack/", ".sticker/", ".stickersequence/"],
33+
apple_product_type.messages_sticker_pack_extension: [
34+
# Replacement for appiconset.
35+
".stickersiconset/",
36+
# The stickers. Ideally we wouldn't list these here, but `app_assets_validation_partial`
37+
# is called with `sticker_assets` instead of just the app icons.
38+
".stickerpack/",
39+
".sticker/",
40+
".stickersequence/",
41+
],
3442
}
3543

3644
# Comprehensive list of all valid icon extensions for each platform. These cover apps, extensions,

apple/internal/resource_actions/actool.bzl

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,33 @@ Found the following: {icon_bundle_files}
7979
8080
""".format(icon_bundle_files = icon_bundle_files))
8181

82+
def _validate_sticker_pack_icon_sets(*, icon_bundle_files, stickers_icon_files, xcasset_appicon_files):
83+
"""Validates that the asset files contain only sticker icon sets."""
84+
message = ("Sticker pack extensions must use Sticker Icon Sets " +
85+
"(named .stickersiconset), not traditional App Icon Sets")
86+
bundling_support.ensure_single_xcassets_type(
87+
extension = "stickersiconset",
88+
files = stickers_icon_files,
89+
message = message,
90+
xcassets_extension = "xcstickers",
91+
)
92+
93+
# Check that there are no .appiconset files, which are not allowed for messages extensions.
94+
bundling_support.ensure_asset_catalog_files_not_in_xcassets(
95+
extension = "appiconset",
96+
files = xcasset_appicon_files,
97+
message = message,
98+
xcassets_extension = "xcstickers",
99+
)
100+
101+
if icon_bundle_files:
102+
fail("""
103+
Icon Composer .icon bundles are not supported for Messages Extensions.
104+
105+
Found the following: {icon_bundle_files}
106+
107+
""".format(icon_bundle_files = icon_bundle_files))
108+
82109
def _validate_tvos_icon_sets(*, brandassets_icon_files, icon_bundle_files, xcasset_appicon_files):
83110
"""Validates that the asset files contain only tvOS brand assets."""
84111
message = ("tvOS apps must use tvOS brand assets (named .brandassets), " +
@@ -198,6 +225,15 @@ def _icon_info_from_asset_files(
198225
stickers_icon_files = icon_files,
199226
xcasset_appicon_files = xcasset_appicon_files,
200227
)
228+
elif product_type == apple_product_type.messages_sticker_pack_extension:
229+
appicon_extension = "stickersiconset"
230+
icon_files = [f for f in asset_files if ".stickersiconset/" in f.path]
231+
_validate_sticker_pack_icon_sets(
232+
icon_bundle_files = icon_bundle_files,
233+
stickers_icon_files = icon_files,
234+
xcasset_appicon_files = xcasset_appicon_files,
235+
)
236+
201237
elif platform_type == "tvos":
202238
appicon_extension = "brandassets"
203239
icon_files = [f for f in asset_files if ".brandassets/" in f.path]
@@ -298,7 +334,10 @@ def _args_for_app_icons(
298334
product_type):
299335
"""Returns arguments for app icons."""
300336
args = []
301-
if product_type == apple_product_type.messages_extension:
337+
if product_type in [
338+
apple_product_type.messages_extension,
339+
apple_product_type.messages_sticker_pack_extension,
340+
]:
302341
args.extend([
303342
"--include-sticker-content",
304343
"--stickers-icon-role",

0 commit comments

Comments
 (0)