Skip to content

Commit f2206a6

Browse files
committed
v1.0
1 parent a479167 commit f2206a6

File tree

3 files changed

+76
-2
lines changed

3 files changed

+76
-2
lines changed

README.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
11
# AssetKit
22

3-
A description of this package.
3+
A command line tool and Swift package for generating image assets for Apple platforms.
4+
5+
# CLI
6+
7+
## Installation
8+
9+
Please download prebuilt binaries from [Releases](https://github.com/xnth97/AssetKit/releases).
10+
11+
## Usage
12+
13+
The CLI `assetool` supports subcommands for generating both `.appiconset` and `.imageset`. Default subcommand is `icon`.
14+
15+
### Icon
16+
17+
```
18+
assetool <input> [-o <output>] [-p <platforms>]
19+
```
20+
21+
`-o, --output <output>`: Path of the output folder. If empty, will use current path of terminal.
22+
23+
`-p, --platforms <platforms>`: Valid values are: `ios`, `iphone`, `ipad`, `mac`, `car`. You can also generate an icon set with multiple platform idioms by sending a string of multiple values separated by comma, e.g. `ios,mac,watch`.
24+
25+
### Image
26+
27+
```
28+
assetool image <input> [-o <output>] [--width <width>] [--height <height>]
29+
```
30+
31+
`--width <width>` and `--height <height>`: @1x width or height of the exported image set. If empty, will use the original width/height as @3x size.
32+
33+
# Package
34+
35+
## Installation
36+
37+
```swift
38+
dependencies: [
39+
.package(url: "https://github.com/xnth97/AssetKit", from: "1.0.0"),
40+
],
41+
```
42+
43+
## Usage
44+
45+
### Icon
46+
47+
```swift
48+
AssetKit.generateIconSet(
49+
inputPath: input,
50+
outputPath: output,
51+
platforms: [.ios, .mac])
52+
```
53+
54+
### Image
55+
56+
```swift
57+
AssetKit.generateImageSet(
58+
inputPath: input,
59+
outputPath: output,
60+
width: width,
61+
height: height)
62+
```
63+
64+
# License
65+
66+
The project is released under MIT license. Please see [LICENSE](LICENSE) for full terms.

Sources/AssetKit/AssetKit.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,24 @@ public struct AssetKit {
2020

2121
private static let generator = AssetGenerator()
2222

23+
/// Generates `.imageset` with a given input image.
24+
/// - Parameters:
25+
/// - inputPath: Path to input image.
26+
/// - outputPath: Path to output folder.
27+
/// - width: @1x width of output image. If left empty, will use image original size as @3x.
28+
/// - height: @1x height of output image. If let empty, will use image original height as @3x.
2329
public static func generateImageSet(inputPath: String,
2430
outputPath: String,
2531
width: CGFloat? = nil,
2632
height: CGFloat? = nil) {
2733
try? generator.generateImageSet(inputPath: inputPath, outputPath: outputPath, width: width, height: height)
2834
}
2935

36+
/// Generates `.appiconset` with a given input image.
37+
/// - Parameters:
38+
/// - inputPath: Path to input image.
39+
/// - outputPath: Path to output folder.
40+
/// - platforms: Platform idioms that need to be included in the generated icon set.
3041
public static func generateIconSet(inputPath: String,
3142
outputPath: String,
3243
platforms: [Platform] = [.ios]) {

Sources/assetool/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extension Assetool {
3434

3535
static var configuration = CommandConfiguration(
3636
abstract: "Generates icon set for Apple platforms. Multiple platform idioms can be merged into one single appiconset",
37-
discussion: "<platforms> flag: Valid values are: 'ios', 'iphone', 'ipad', 'mac', 'tv', 'car'. To generate an icon set with multiple platform idioms, multiple values should be separated by comma, e.g. 'ios,mac,watch'")
37+
discussion: "<platforms> flag: Valid values are: 'ios', 'iphone', 'ipad', 'mac', 'car'. To generate an icon set with multiple platform idioms, multiple values should be separated by comma, e.g. 'ios,mac,watch'")
3838

3939
func run() throws {
4040
let parsedPlatforms: [AssetKit.Platform] = platforms.split(separator: ",").map { platformStr in

0 commit comments

Comments
 (0)