Swiftpack.co -  pawello2222/AppIconGenerator as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
pawello2222/AppIconGenerator
A library for creating App Icons from SwiftUI views.
.package(url: "https://github.com/pawello2222/AppIconGenerator.git", from: "0.2.0")

Build Language Supported Platform Swift Package Manager Release version License


AppIconGenerator

A library for creating App Icons from SwiftUI views.

Installation

AppIconGenerator is available as a Swift Package.

Examples

Assuming we have a SwiftUI view:

struct IconView: View { ... }

we can save it directly to a file:

IconView()
    .generateIcons()

By default it creates icons for all App Icon sizes:

static let appIconSizes = [20, 29, 40, 58, 60, 76, 80, 87, 120, 152, 167, 180, 1024]

However, you're free to modify the parameters as you wish:

AppIconGenerator.shared.generateIcons(from: IconView(), filename = "Icon", sizes = [100, 200, 300])

Full demo:

import AppIconGenerator
import SwiftUI

struct ContentView: View {
    var body: some View {
        IconView()
            .frame(width: 100, height: 100)
            .generateIcons()
    }
}

struct IconView: View {
    var body: some View {
        GeometryReader { geometry in
            ZStack {
                Color.blue
                Circle()
                    .fill(Color.red)
                    .frame(width: geometry.size.width / 2, height: geometry.size.height / 2)
            }
        }
    }
}

Output

Generated icons will be saved in the documents directory (the full path will be printed to the console):

File saved to: /Users/.../Library/Developer/CoreSimulator/Devices/.../Documents/Icon1024.png

License

AppIconGenerator is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 11
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

0.2.0
5 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API