xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.45k stars 511 forks source link

Add support for alternate app icons, and MSBuild items/properties to include them in Info.plist #12790

Open Redth opened 3 years ago

Redth commented 3 years ago

iOS Apps support the ability to set alternate app icons

Currently there's an info.plist key XSAppIconAssets which specifies which icon is to be used as the primary/default app icon.

Can we modernize how we include these assets by allowing support for MSBuild items/properties, and also include the ability to include multiple icon assets and have them all registered properly in the info.plist?

Something like this:

<ItemGroup>
  <!-- One icon can be primary -->
  <BundleResource Include="Assets.xcassets/appicon.appiconset" RegisterPrimaryBundleIcon="True" />

  <!-- Zero or more alternate icons -->
  <BundleResource Include="Assets.xcassets/alternateappicon.appiconset" RegisterAlternateBundleIcon="True" />
  <BundleResource Include="Assets.xcassets/alternateappicon2.appiconset" RegisterAlternateBundleIcon="True" />
</ItemGroup>

In the Info.plist would generate something like this:

<key>CFBundleIcons</key>
<dict>
  <key>CFBundlePrimaryIcon</key>
  <dict>
    <key>CFBundleIconName>
    <string>appicon</string>
    <key>CFBundleIconFiles</key>
    <array><!-- ... --></array>
  </dictionary>

  <key>CFBundleAlternateIcons</key>
  <dict>
    <key>alternateappicon</key>
    <dict>
      <key>CFBundleIconFiles</key>
      <array><!-- ... --></array>
    </dict>
    <key>alternateappicon2</key>
    <dict>
      <key>CFBundleIconFiles</key>
      <array><!-- ... --></array>
    </dict>
  </dict>
</dict>
yuriibabii commented 1 year ago

Hey guys, I found a hackish way to do that. You might want to check it out: https://stackoverflow.com/a/77050207/6157156

lakhan-bairawat commented 3 months ago

how we can achieved this in android like :- iOS Apps support the ability to [set alternate app icons]