You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何向iOS模拟器添加HEIC图片?xcrun命令执行失败求助

Fixing HEIC Media Addition on iPhone 6 Simulator

Got it, let's break down why you're hitting this issue and how to work around it to test your app's HEIC compatibility.

First, the root cause: The iPhone 6 (even its simulator) doesn't have hardware support for HEIC decoding, and the iOS version it runs (max iOS 12) relies on hardware acceleration for HEIC handling. That's why xcrun simctl addmedia works for JPG but fails for HEIC— the simulator's system can't recognize or process the HEIC file natively.

Here are your practical solutions:

1. Use a HEIC-supported simulator model

This is the most reliable way to test your app's HEIC compatibility, since it mimics a device that natively supports the format:

  • Open Xcode, go to Window > Devices and Simulators
  • Switch to the Simulators tab, click the + button at the bottom-left to create a new simulator
  • Select an iPhone 7 or newer model (all these have native HEIC support), paired with iOS 11 or later
  • Launch this new simulator, then re-run your command: xcrun simctl addmedia booted ./IMG_0237.HEIC
  • The HEIC file should be added to the simulator's Photos app without issues

2. Try manual drag-and-drop into the simulator

While the iPhone 6 simulator doesn't natively support HEIC at the system level, some users have had success manually importing files directly into the Photos app:

  • Launch your iPhone 6 simulator and open the Photos app
  • From Finder, drag your HEIC file directly onto the simulator's Photos app window
  • The simulator may attempt software-based decoding (though this isn't guaranteed, it's worth a quick test)

3. Integrate a third-party HEIC decoder into your app (if you're the developer)

If you need to test your app's ability to handle HEIC files even on non-supported devices like the iPhone 6, bypass the system's limitations:

  • Add a third-party HEIC decoding library (like libheif) to your app's project
  • This lets your app directly decode HEIC files without relying on the device's native support
  • You can include the HEIC file in your app's bundle, or transfer it to the simulator via xcrun simctl addfile instead of addmedia, then load it directly in your app for testing

If your main goal is to validate your app's HEIC compatibility, option 1 is your best bet— it replicates a real-world scenario where users have HEIC-supported devices.

内容的提问来源于stack exchange,提问作者Pedro Hidalgo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:17:28