peterpoliwoda GitHub avatar

icon-composer-template

peterpoliwoda

IconComposerModel 是一个 Swift 包,提供了苹果 Icon Composer 工具中 icon.json 文件的模型与参考实现,使应用能够检查、生成或修改 .icon 包。

Stars

10

7 天增长

暂无数据

Fork 数

0

开放 Issue

0

开源协议

暂无数据

最近更新

2026-07-29

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

苹果未将 icon.json 的 schema 作为公共 API 发布,这个基于实际文件推导的参考填补了开发者在处理 Icon Composer 文件时的关键空白。

适合谁使用

  • 开发图标生成或检查工具的程序员
  • 使用 Icon Composer 的 macOS/iOS 开发者
  • 验证图标文件跨系统兼容性的质量工程师

典型使用场景

  • 解析并验证现有的 .icon 包以便迁移或测试
  • 以编程方式生成新的 .icon 包以实现自动化图标创建
  • 编辑构图属性,如填充、渐变、图层和外观特殊化设置

项目优势

  • 开放字符串支持的枚举值允许解码未来的混合模式、外观和平台,无需等待包更新
  • 通过 IconColor 保留原始色彩空间和精度,避免转换为平台特定类型
  • 基于真实文件支持复杂的特殊化机制和多种 JSON 表示形式(如 blur 与 blur-material)

使用前须知

  • 模式基于经验推导,可能未覆盖所有 Icon Composer 版本或边界情况
  • 未知属性以 JSONValue 形式存储,需要手动映射才能实现完全无损的往返
  • 未来 Icon Composer 更新可能引入新属性,需更新包以避免数据丢失

README 快速开始

IconComposerModel

IconComposerModel is a Swift package and a living reference for the contents of Apple Icon Composer's icon.json file. It is intended for apps and tools that need to inspect, generate, or modify .icon packages.

[!IMPORTANT] Apple documents how to use Icon Composer, but does not currently publish the icon.json schema as a public API. This reference is empirical. It will be updated from real files produced by different Icon Composer versions.

Add the package

Add this repository as a Swift Package dependency, then import the library:

import IconComposerModel

let iconJSON = iconPackageURL.appending(path: "icon.json")
let icon = try IconComposerIcon.decode(contentsOf: iconJSON)

print(icon.groups.count)
print(icon.groups.flatMap(\.layers).map(\.name))

To encode a modified model:

let data = try icon.encoded()
try data.write(to: iconJSON, options: .atomic)

The package uses open, string-backed values for evolving options such as blend modes and appearances. A newer value can therefore be decoded without waiting for a package update.

Package layout

A saved .icon file is a package (a directory presented as one file in Finder):

AppIcon.icon/
├── icon.json
└── Assets/
    ├── Background.svg
    └── Symbol.png

icon.json describes composition and rendering. The Assets directory contains the SVG or bitmap artwork named by image-name.

Attribute reference

Unless noted otherwise, attributes are optional. Icon Composer commonly omits a property when it has its default value.

Top-level icon

JSON attributeSwift propertyMeaning
fillfillBackground fill used when no appearance-specific fill overrides it.
fill-specializationsfillSpecializationsBackground fills for particular appearances.
color-space-for-untagged-svg-colorscolorSpaceForUntaggedSVGColorsInterprets colors in imported SVGs that have no embedded color-space tag. Observed values: srgb, display-p3.
groupsgroupsOrdered collection of Liquid Glass groups that make up the icon.
supported-platformssupportedPlatformsDeclares which enclosure families/platforms the design supports.

Fill

A fill is normally an object with one of these attributes:

JSON formMeaning
{"solid": ""}One flat co

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

Blaizzy
精选
Blaizzy GitHub avatar

nativ

Nativ is a native macOS app that lets you run AI models locally on Apple silicon, offering chat, model management, performance analytics, and an OpenAI/Anthropic-compatible API server.

AI 与机器学习AI 视觉与语音
985
uzairansaruzi
精选
uzairansaruzi GitHub avatar

hermex

Hermex is a native SwiftUI iPhone app that lets you control a self-hosted Hermes AI agent directly from your phone, with no subscriptions, tracking, or third-party relay.

AI 与机器学习大语言模型
941
simonw
精选
simonw GitHub avatar

speech-analyzer-cli

A macOS command-line tool that uses Apple's on-device speech APIs to transcribe prerecorded audio into plain text, JSON, JSONL, SRT, or WebVTT.

开发者工具CLI 与终端
20