AppIcon

2.0.5

A simple Swift utility for managing and retrieving app icon details in iOS
kevinhermawan/AppIcon

What's New

v2.0.5

2023-10-11T10:37:06Z

AppIcon

A simple Swift utility for managing and retrieving app icon details in iOS.

Overview

The AppIcon struct provides static properties and functions that facilitate seamless interaction with your application's icon settings. With capabilities to check for alternate icon support, determine the current icon, fetch all defined icons, and set an alternate icon.

Installation

You can add AppIcon as a dependency to your project using Swift Package Manager by adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/kevinhermawan/AppIcon.git", .upToNextMajor(from: "2.0.0"))
]

Alternatively, in Xcode:

  1. Open your project in Xcode.
  2. Click on File -> Swift Packages -> Add Package Dependency...
  3. Enter the repository URL: https://github.com/kevinhermawan/AppIcon.git
  4. Choose the version you want to add. You probably want to add the latest version.
  5. Click Add Package.

Usage

import AppIcon

// Checking if alternate icons are supported
if AppIcon.isSupported {
    print("Alternate icons are supported!")
} else {
    print("Alternate icons are not supported.")
}

// Fetching the current app icon details
if let currentIcon = AppIcon.current {
    print("Current app icon: \(currentIcon.label) - \(currentIcon.iconName)")
} else {
    print("Using default app icon")
}

// Fetching all defined icons
for icon in AppIcon.defined {
    print("\(icon.label) - \(icon.iconName)")
}

// Retrieving a specific icon by its iconName
let iconName = "Alternate1"

if let specificIcon = AppIcon.icon(for: iconName) {
    print("Found icon: \(specificIcon.label) - \(specificIcon.iconName)")
} else {
    print("Icon not found for name \(iconName)")
}

// Setting an alternate app icon (for example, "Alternate1")
if let iconToSet = AppIcon.defined.first(where: { $0.iconName == "Alternate1" }) {
    AppIcon.set(to: iconToSet) { error in
        if let error = error {
            print("Failed to set app icon: \(error.localizedDescription)")
        } else {
            print("App icon successfully set!")
        }
    }
} else {
    print("Failed to find the specified icon.")
}

License

MIT License

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Apr 05 2024 00:52:59 GMT-0900 (Hawaii-Aleutian Daylight Time)