如何使用devicectl appIcon命令成功提取iOS应用图标?
如何通过devicectl成功提取iOS 17.0.2设备上的应用图标?
我尝试用xcrun devicectl的appIcon命令,从运行iOS 17.0.2的iPhone 14 Pro提取应用图标。按照命令文档试过多种参数组合,甚至同时指定--app-bundle-id和--app-path,但始终失败。
执行命令:
xcrun devicectl device info appIcon --device *** --app-bundle-id *** --app-path *** --allow-placeholder true --width 60 --height 60 --scale 3 --destination icon.png -j icon.json -t 10 -v
得到的JSON输出错误信息:
错误码6007,错误域为com.apple.dt.CoreDeviceError,提示“CGImage was nil when attempting to write to a destination.”
如果不输出JSON,返回的图标尺寸、缩放比例均为0.0。
解决步骤
- 不要同时指定
--app-bundle-id和--app-path:这两个参数互斥,仅需保留其中一个即可。优先用--app-bundle-id定位应用,无需手动指定路径,可靠性更高。 - 匹配应用实际存在的图标规格:iOS应用图标有固定尺寸规范,比如60x60@3x是iPhone主图标尺寸,但部分应用可能没有该规格图标。可先不指定
--width/--height/--scale,让命令自动提取默认图标,再按需调整参数。 - 确保Xcode工具链与iOS版本兼容:iOS 17.0.2需要搭配Xcode 15.x及以上版本,旧版Xcode的
devicectl可能不支持新系统。运行xcodebuild -version确认版本匹配。 - 移除
--allow-placeholder参数重试:若应用本身有真实图标,该参数可能干扰提取逻辑,先关闭占位符允许再尝试。 - 用最简命令验证基础功能:先执行极简命令确认核心功能正常,再逐步添加参数:
xcrun devicectl device info appIcon --device [设备UDID] --app-bundle-id [应用Bundle ID] --destination test.png
内容的提问来源于stack exchange,提问作者J_J
相关产品推荐
相关产品推荐

