configureAppIcon
从源图生成 iOS AppIcon.appiconset 所需多尺寸图标。
前置依赖
| 参数名 | 类型 | 说明 |
|---|---|---|
deps.existsSync / readFileSync / writeFileSync | 文件 IO | 读写 PNG 与 Contents.json |
deps.join / dirname | Path | 路径 |
deps.sharp | Sharp | 缩放与格式转换 |
环境要求
- Node.js + sharp
函数签名
typescript
function configureAppIconIOS(
imagePath: string,
projectPath: string,
deps: ConfigureAppIconIOSDeps,
): Promise<ConfigureAppIconIOSResult>参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
imagePath | string | 是 | 1024×1024 推荐 |
projectPath | string | 是 | 含 .xcodeproj 的 iOS 工程 |
deps | ConfigureAppIconIOSDeps | 是 | fs / path / sharp |
返回值
| 类型 | 说明 |
|---|---|
ConfigureAppIconIOSResult | { success, error?, logs[] } |
工作原理
- 定位或创建
Assets.xcassets/AppIcon.appiconset。 - 按 Apple 要求尺寸列表用 sharp 生成 PNG。
- 更新
Contents.json引用各 idiom/scale 文件。