
关于
从 SF Symbols(5000+ 苹果原生图标)或 Iconify 生成 iOS 应用图标,输出为 Xcode 资产目录的 PNG 图像集。
name: ios-icon-gen description: 为 Xcode 资源目录生成 iOS 应用图标 PNG 图像集,支持 SF Symbols(5000+ Apple 原生图标)或 Iconify API(来自 200+ 图标集的 275k+ 开源图标)。适用于生成图标、创建图标资源、向资源目录添加图标或为 iOS 项目搜索图标。 origin: community
iOS 图标生成器
从两个来源为 Xcode 资源目录生成 PNG 图标图像集。
何时激活
- 为 iOS/macOS Xcode 项目生成图标资源
- 在开源图标集中搜索图标
- 为资源目录创建 PNG 图像集(1x、2x、3x)
- 用生产级资源替换占位图标
- 匹配 Xcode 项目中现有的图标风格
核心原则
1. 两个来源,统一输出格式
两个来源都生成相同的 Xcode 兼容图像集,根据需求选择:
| 来源 | 图标数量 | 要求 | 最适合 | |------|----------|------|--------| | Iconify API | 来自 200+ 图标集的 275,000+ | 需要网络 | 丰富选择、特定风格、开源图标 | | SF Symbols | 5,000+ Apple 符号 | 仅限 macOS | Apple 原生风格、离线使用 |
2. 始终匹配现有风格
生成前,检查项目现有图标的尺寸、颜色和粗细一致性。
3. 输出结构
两种方法都生成完整的 Xcode 图像集:
<output-dir>/<asset-name>.imageset/
Contents.json
<asset-name>.png # 1x (默认 68px)
<asset-name>@2x.png # 2x (默认 136px)
<asset-name>@3x.png # 3x (默认 204px)
使用示例
步骤 1:评估需求
确定图标需求:图标代表什么、偏好风格、目标颜色和尺寸。
如果项目已有图标,检查现有风格:
# 检查现有图标的尺寸
sips -g pixelWidth -g pixelHeight path/to/existing@2x.png
步骤 2:搜索图标
Iconify API(推荐,选择范围广):
# 搜索所有图标集
$SKILL_DIR/scripts/iconify_gen.sh search "receipt"
# 在特定图标集中搜索
$SKILL_DIR/scripts/iconify_gen.sh search "business card" --prefix mdi
# 列出可用图标集
$SKILL_DIR/scripts/iconify_gen.sh collections
SF Symbols(Apple 原生风格): 浏览 SF Symbols 应用或参考常用名称:
| 用途 | 符号名称 |
|------|----------|
| 文档 | doc.text、doc.fill |
| 收据 | doc.text.below.ecg、receipt |
| 人物 | person.crop.rectangle、person.text.rectangle |
| 相机 | camera、camera.fill |
| 扫描 | doc.viewfinder、qrcode.viewfinder |
| 设置 | gearshape、slider.horizontal.3 |
步骤 3:预览(可选)
# Iconify 预览
$SKILL_DIR/scripts/iconify_gen.sh preview mdi:receipt-text-outline
步骤 4:生成
Iconify API:
# 基本生成
$SKILL_DIR/scripts/iconify_gen.sh mdi:receipt-text-outline editTool_expenseReport
# 自定义颜色和输出位置
$SKILL_DIR/scripts/iconify_gen.sh mdi:receipt-text-outline myIcon --color 007AFF --output ./Assets.xcassets/icons
选项:--size <pt>(默认:68)、--color <hex>(默认:8E8E93)、--output <dir>(默认:/tmp/icons)
SF Symbols:
# 基本生成
swift $SKILL_DIR/scripts/generate_icons.swift doc.text.below.ecg editTool_expenseReport
# 自定义颜色、粗细和输出位置
swift $SKILL_DIR/scripts/generate_icons.swift person.crop.rectangle myIcon --color 007AFF --weight regular --output ./Assets.xcassets/icons
选项:--size <pt>(默认:68)、--color <hex>(默认:8E8E93)、--weight <name>(默认:thin)、--output <dir>(默认:/tmp/icons)
步骤 5:验证与集成
- 读取生成的 @2x PNG 进行视觉验证
- 如果未直接输出到资源目录,复制到资源目录:
cp -r /tmp/icons/<name>.imageset path/to/Assets.xcassets/<group>/ - 构建项目以验证 Xcode 正确识别新资源
常用 Iconify 图标集
| 前缀 | 名称 | 数量 | 风格 |
|------|------|------|------|
| mdi | Material Design Icons | 7400+ | 填充 + 轮廓变体 |
| ph | Phosphor | 9000+ | 每个图标 6 种粗细 |
| solar | Solar | 7400+ | 粗体、线性、轮廓 |
| tabler | Tabler Icons | 6000+ | 统一描边宽度 |
| lucide | Lucide | 1700+ | 简洁、极简 |
| ri | Remix Icon | 3100+ | 填充 + 线条变体 |
| carbon | Carbon | 2400+ | IBM 设计语言 |
| heroicons | HeroIcons | 1200+ | Tailwind CSS 配套 |
浏览全部:https://icon-sets.iconify.design/
脚本参考
| 脚本 | 来源 | 路径 |
|------|------|------|
| iconify_gen.sh | Iconify API(275k+ 图标) | $SKILL_DIR/scripts/iconify_gen.sh |
| generate_icons.swift | SF Symbols(5k+ 图标) | $SKILL_DIR/scripts/generate_icons.swift |
最佳实践
- 先搜索再生成 -- 浏览可用图标以找到最佳匹配
- 匹配现有项目风格 -- 检查现有图标的尺寸、颜色和粗细
