a Swift Library to generate an Xcode
AppIcon.appiconset
from a SwiftUI view.
This is how you get started using ViewToAppIconSet in your project.
ViewToAppIconSet is distributed using the Swift Package Manager. Install it in a project by adding it as a dependency in your Package.swift manifest or through "Package Dependencies" in project settings.
git@github.com:StefKors/ViewToAppIconSet.git
let package = Package(
dependencies: [
.package(url: "git@github.com:StefKors/ViewToAppIconSet.git", from: "0.1.0")
]
)
If you find this package useful, please star the repo ⭐️
Create a view with your App Icon and use SwiftUI Previews to design.
import ViewToAppIconSet
import SwiftUI
struct AppIcon: View {
@IconRelativeMetric var padding = 10 /// 10% padding
let color: Color
var body: some View {
ContainerRelativeShape()
.fill(Color.accentColor)
.overlay(content: {
Image(systemName: "circle.hexagongrid.fill")
.resizable()
.scaledToFit()
.padding(padding)
})
}
}
struct AppIcon_Previews: PreviewProvider {
static var previews: some View {
AppIcon()
.iconStyle(.macOS)
.frame(width: 100, height: 100, alignment: .center)
.scenePadding()
}
}
Call generateAppIconSet
to generate the AppIconSet images
import ViewToAppIconSet
let path = try generateAppIconSet(from: AppIcon())
The output has the following structure:
AppIcon.appiconset
├── Contents.json
├── appstore1024.png
├── ipad152.png
├── ipad76.png
├── ipadNotification20.png
├── ipadNotification40.png
├── ipadPro167.png
├── ipadSettings29.png
├── ipadSettings58.png
├── ipadSpotlight40.png
├── ipadSpotlight80.png
├── iphone120.png
├── iphone180.png
├── mac1024.png
├── mac128.png
├── mac16.png
├── mac256.png
├── mac32.png
├── mac512.png
├── mac64.png
├── notification40.png
├── notification60.png
├── settings58.png
├── settings87.png
├── spotlight120.png
└── spotlight80.png