Swiftpack.co - pawello2222/AppIconGenerator as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by pawello2222.
pawello2222/AppIconGenerator 1.0.1
A library for creating App Icons from SwiftUI views.
⭐️ 18
🕓 38 weeks ago
iOS macOS
.package(url: "https://github.com/pawello2222/AppIconGenerator.git", from: "1.0.1")

App Icon Generator logo

Build Language Supported platforms Swift Package Manager Release version License

App Icon Generator

A library for creating App Icons from SwiftUI views.

Table of Contents
  1. Installation
  2. Highlights
  3. Icon sets
  4. Demo
  5. License

Installation

Requirements

  • iOS 16.0+
  • macOS 13.0+

Swift Package Manager

App Icon Generator is available as a Swift Package.

.package(url: "https://github.com/pawello2222/AppIconGenerator.git", .upToNextMajor(from: "1.0.0"))

Highlights

Generate icons using AppIconGenerator

AppIconGenerator {
    IconView()
}
.generateIcons(for: .iOS)

or directly from within a SwiftUI block

IconView()
    .generateIcons(for: .iOS)

Output

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

  • iOS

Icon saved to: /Users/.../Library/Developer/CoreSimulator/.../Documents/AppIconGenerator/Icon/Icon-1024.png

  • macOS

Icon saved to: /Users/.../Documents/AppIconGenerator/Icon/Icon-1024.png

Icon sets

extension IconSet {
    public var sizes: [CGFloat] {
        switch self {
        case .iOS:
            return [40, 58, 60, 76, 80, 87, 114, 120, 128, 136, 152, 167, 180, 192, 1024]
        case .macOS:
            return [16, 32, 64, 128, 256, 512, 1024]
        case .watchOS:
            return [44, 48, 55, 58, 60, 64, 66, 80, 87, 88, 92, 100, 102, 108, 172, 196, 216, 234, 258, 1024]
        case .single:
            return [1024]
        case .custom(let sizes):
            return sizes
        }
    }
}

Demo

import AppIconGenerator
import SwiftUI

struct ContentView: View {
    var body: some View {
        IconView()
            .generateIcons(for: .iOS, name: "MyIcon")
    }
}

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
                    )
            }
        }
    }
}

License

App Icon Generator is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 18
Last commit: 38 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

1.0.1
38 weeks ago

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