-
Notifications
You must be signed in to change notification settings - Fork 984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(icons)!: Support a single 1024⨉1024 icon, but also more complex customizations #1465
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1465 +/- ##
==========================================
+ Coverage 78.31% 80.22% +1.91%
==========================================
Files 16 16
Lines 1826 1871 +45
==========================================
+ Hits 1430 1501 +71
+ Misses 396 370 -26 ☔ View full report in Codecov by Sentry. |
8fc533d
to
3ea57bf
Compare
3ea57bf
to
ec95b10
Compare
8a04ef6
to
168eb8b
Compare
We've got one issue to sort out here, and it's related to the new iOS 18 icon variants and Xcode support. Icon variants are only supported/understood by Xcode 16. If you set up icon variants, and then open the project in Xcode 15 (or lower) it will see 3 icons trying to fill the same slot and pick one at random (and almost always one of the variants instead of the default icon). I already tried reordering the icons in Contents.json and that did not produce consistent behaviour 😞 One option (and the easiest) is to document this behaviour and say that specifying icon variants only works with Xcode 16 and up. Documentation gives us something to point to when people open issues about it, but I have low confidence in its ability to prevent issues from being opened. The second option (and what I tried to do here) is to detect the Xcode version at prepare-time and only add the icon variants if it's 16 or higher. This works great on macOS. However, we support adding and preparing the iOS platform on other OSes where Xcode is not present, and that prepare-time check is failing. So the question here is what to do about those other platforms, do we make them pretend to be Xcode 15 (and skip the variants) or Xcode 16 (and potentially include broken variants)? Would be good to get some feedback or other proposals for how best to handle this @jcesarmobile @breautek @erisu |
Ironically, this also allows most people to drastically simplify their icons by only providing a single 1024⨉1024 image with no special attributes. Closes apacheGH-592. Closes apacheGH-623. Closes apacheGH-657. Closes apacheGH-658. Closes apacheGH-1019. Closes apacheGH-1233. Closes apacheGH-1387.
8f5bed2
to
f29f35c
Compare
I would go with the second option. As for anyone who runs the As of right now, building an app with Xcode 16 is not a hard requirement of the App Store and I believe it wont be until April 2025. Once it becomes a hard requirement, then we can remove the version check and default the variants setup for all systems. |
Xcode 15 doesn't understand the appearance variants, and if variants are specified then it thinks there are 3 images assigned to the same slot and ends up picking one at random and we don't want that.
f29f35c
to
d63d690
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes LGTM
I tested and confirmed that:
- Xcode 16 Beta 5 will generate entries for dark and tinted icons in
Assets.xcassets/AppIcon.appiconset/Contents.json
when the icon'sforeground
andmonochrome
properties are defined inconfig.xml
. - Xcode 16 Beta 5 will NOT generate entries for dark and tinted icons in
Assets.xcassets/AppIcon.appiconset/Contents.json
when the icon does NOT define aforeground
andmonochrome
properties inconfig.xml
. - Xcode 16 Beta 5 will NOT generate entries for dark icon in
Assets.xcassets/AppIcon.appiconset/Contents.json
when the icon'sforeground
property is NOT defined inconfig.xml
. - Xcode 16 Beta 5 will NOT generate entries for tinted icon in
Assets.xcassets/AppIcon.appiconset/Contents.json
when the icon'smonochrome
property is NOT defined inconfig.xml
. - Xcode 15.4 will NOT generate entries for dark and tinted icons in
Assets.xcassets/AppIcon.appiconset/Contents.json
when the icon'sforeground
andmonochrome
properties are defined inconfig.xml
.
Platforms affected
iOS (watchOS, and macOS Catalyst technically)
Motivation and Context
Xcode now supports generating all the app icons sizes automatically from a single 1024⨉1024 PNG image. Supporting this drastically simplifies the requirements for app developers.
That said, there are cases where an app developer might want to provide specific icons for specific situations (such as watchOS notifications, or a macOS Catalyst app) and historically Cordova has been pretty bad at supporting those customizations due to relying solely on image sizes to handle mappings.
iOS 18 is also introducing dark mode and tinted app icon variants, and we need a way to support those.
Description
Simple case
For the simplest case, an app developer can provide a single 1024⨉1024 icon image and list it in their config.xml file with no attributes:
With iOS 18 variants
We make use of the
foreground
andmonochrome
attributes, already supported in Cordova Android, to handle the dark mode and tint-able icon variants.The dark mode icon should have a transparent background (hence, the
foreground
attribute).The tint-able icon should be a greyscale mask that gets multiplied by the system tint colour (hence, the
monochrome
attribute).Example images:
Example config:
You can provide variants for all iOS icons (but variants are not supported on watchOS or macOS Catalyst).
Platform-specific icons
Apple watchOS supports the same automatic generation of icons from a single 1024⨉1024 icon. By default this will use the app icon, but it can be overridden by providing another icon with a
target
attribute.Supported targets are
watchos
andmac
. There's a special case targetspotlight
for iOS to disambiguate some icons that otherwise have identical sizes (only applicable if you are providing all your own icon sizes).The macOS icons do not support a single 1024⨉1024 image, so if you want to customize those then you will need to provide all the required icon sizes yourself.
Providing all the icon sizes
If you prefer to provide all the icons yourself, you can still do so. Note that if you provide any sized icons, you are required to provide all the sized icons for that platform.
You can also provide all the icons for the
watchos
andmac
targets, with all their respective sizes.Testing
Closed issues
Closes #592.
Closes #623.
Closes #657.
Closes #658.
Closes #1019.
Closes #1233.
Closes #1387.
Closes #1462.
Checklist