
Dynamic runtime switching of app launcher icons with a zero-UI API; safe-by-default alias validation on Android, main-thread iOS calls, no CocoaPods required.
Lightweight Kotlin Multiplatform library for dynamic app icon switching at runtime—change alternate launcher icons on Android (<activity-alias>) and iOS (UIApplication.setAlternateIconName) from shared Kotlin code.
UIKit APIs directly via Kotlin/Native.| Platform | Target | Minimum OS |
|---|---|---|
| Android | androidTarget |
API 21 (Android 5.0+) |
| iOS |
iosArm64, iosX64, iosSimulatorArm64
|
iOS 13.0+ |
// build.gradle.kts (shared / composeApp)
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.ahmedn-mohamed:kmp-app-icon:0.1.0")
}
}
}import io.github.ahmednmohamed.appicon.appIconConfig
val AppIcons = appIconConfig {
default(
id = "default",
androidAlias = ".MainActivityDefault",
)
alternate(
id = "ramadan",
androidAlias = ".MainActivityRamadan",
iosIconName = "RamadanIcon",
)
alternate(
id = "dark",
androidAlias = ".MainActivityDark",
iosIconName = "DarkIcon",
)
}Android (androidMain):
import io.github.ahmednmohamed.appicon.AppIconManager
import io.github.ahmednmohamed.appicon.createAppIconManager
val iconManager: AppIconManager = createAppIconManager(context, AppIcons)iOS (iosMain):
import io.github.ahmednmohamed.appicon.AppIconManager
import io.github.ahmednmohamed.appicon.createAppIconManager
val iconManager: AppIconManager = createAppIconManager(AppIcons)import io.github.ahmednmohamed.appicon.AppIconManager
import io.github.ahmednmohamed.appicon.AppIconResult
suspend fun onSelectIcon(iconManager: AppIconManager, iconId: String) {
if (!iconManager.isSupported()) return
when (val result = iconManager.setIcon(iconId)) {
is AppIconResult.Changed -> println("Switched to ${result.icon.id}")
is AppIconResult.AlreadyActive -> println("Already using ${result.icon.id}")
AppIconResult.Unsupported -> println("Alternate icons not supported")
is AppIconResult.Failure -> println("Failed: ${result.reason}")
}
}
// Read active icon
val current = iconManager.getCurrentIcon()
// Reset back to default
iconManager.resetToDefault()MAIN/LAUNCHER <intent-filter> from your main <activity>.<activity-alias> per icon pointing to your main activity. Keep only the default alias android:enabled="true":<activity
android:name=".MainActivity"
android:exported="true">
<!-- Keep deep-link intent-filters here, NOT MAIN/LAUNCHER -->
</activity>
<activity-alias
android:name=".MainActivityDefault"
android:enabled="true"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity-alias
android:name=".MainActivityRamadan"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_ramadan"
android:roundIcon="@mipmap/ic_launcher_ramadan_round"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>Note: On Android,
PackageManager.setComponentEnabledSettingrefreshes the launcher icon asynchronously (usually within 1–5 seconds depending on the OEM launcher). PassingAppIconOptions(androidDontKillApp = true)(the default) avoids immediately terminating the app.
RamadanIcon, DarkIcon) to Assets.xcassets.Include All App Icon Assets (ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES).Include <IconName>@2x.png and <IconName>@3x.png in your app target resources and declare CFBundleIcons (plus CFBundleIcons~ipad if supporting iPad) in Info.plist:
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>RamadanIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>RamadanIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
</dict>
</dict>Apache License 2.0 — see LICENSE.
Lightweight Kotlin Multiplatform library for dynamic app icon switching at runtime—change alternate launcher icons on Android (<activity-alias>) and iOS (UIApplication.setAlternateIconName) from shared Kotlin code.
UIKit APIs directly via Kotlin/Native.| Platform | Target | Minimum OS |
|---|---|---|
| Android | androidTarget |
API 21 (Android 5.0+) |
| iOS |
iosArm64, iosX64, iosSimulatorArm64
|
iOS 13.0+ |
// build.gradle.kts (shared / composeApp)
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.ahmedn-mohamed:kmp-app-icon:0.1.0")
}
}
}import io.github.ahmednmohamed.appicon.appIconConfig
val AppIcons = appIconConfig {
default(
id = "default",
androidAlias = ".MainActivityDefault",
)
alternate(
id = "ramadan",
androidAlias = ".MainActivityRamadan",
iosIconName = "RamadanIcon",
)
alternate(
id = "dark",
androidAlias = ".MainActivityDark",
iosIconName = "DarkIcon",
)
}Android (androidMain):
import io.github.ahmednmohamed.appicon.AppIconManager
import io.github.ahmednmohamed.appicon.createAppIconManager
val iconManager: AppIconManager = createAppIconManager(context, AppIcons)iOS (iosMain):
import io.github.ahmednmohamed.appicon.AppIconManager
import io.github.ahmednmohamed.appicon.createAppIconManager
val iconManager: AppIconManager = createAppIconManager(AppIcons)import io.github.ahmednmohamed.appicon.AppIconManager
import io.github.ahmednmohamed.appicon.AppIconResult
suspend fun onSelectIcon(iconManager: AppIconManager, iconId: String) {
if (!iconManager.isSupported()) return
when (val result = iconManager.setIcon(iconId)) {
is AppIconResult.Changed -> println("Switched to ${result.icon.id}")
is AppIconResult.AlreadyActive -> println("Already using ${result.icon.id}")
AppIconResult.Unsupported -> println("Alternate icons not supported")
is AppIconResult.Failure -> println("Failed: ${result.reason}")
}
}
// Read active icon
val current = iconManager.getCurrentIcon()
// Reset back to default
iconManager.resetToDefault()MAIN/LAUNCHER <intent-filter> from your main <activity>.<activity-alias> per icon pointing to your main activity. Keep only the default alias android:enabled="true":<activity
android:name=".MainActivity"
android:exported="true">
<!-- Keep deep-link intent-filters here, NOT MAIN/LAUNCHER -->
</activity>
<activity-alias
android:name=".MainActivityDefault"
android:enabled="true"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity-alias
android:name=".MainActivityRamadan"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_ramadan"
android:roundIcon="@mipmap/ic_launcher_ramadan_round"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>Note: On Android,
PackageManager.setComponentEnabledSettingrefreshes the launcher icon asynchronously (usually within 1–5 seconds depending on the OEM launcher). PassingAppIconOptions(androidDontKillApp = true)(the default) avoids immediately terminating the app.
RamadanIcon, DarkIcon) to Assets.xcassets.Include All App Icon Assets (ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES).Include <IconName>@2x.png and <IconName>@3x.png in your app target resources and declare CFBundleIcons (plus CFBundleIcons~ipad if supporting iPad) in Info.plist:
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>RamadanIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>RamadanIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
</dict>
</dict>Apache License 2.0 — see LICENSE.