tauri-apps/tauri · error · io::Error

No matching IconType

Error message

No matching IconType

What it means

When building an .icns file, add_icon_to_family maps each PNG icon size to an icns IconType via IconType::from_png. If the image's dimensions don't correspond to any known ICNS icon type, the function returns this InvalidData io::Error instead of adding an icon to the family.

Solutions

  1. Resize every icon listed in tauri.conf.json to standard square ICNS sizes (16, 32, 64, 128, 256, 512, 1024 px), ideally 1024x1024 as the single source
  2. Regenerate the icon set with `tauri icon path/to/icon.png` so all sizes are produced correctly
  3. Verify the PNG decodes to the expected dimensions (e.g. with `file icon.png` or an image tool) before bundling

Example fix

// before (tauri.conf.json)
"icon": ["./icons/custom-300x300.png"]
// after
"icon": ["./icons/32x32.png", "./icons/128x128.png", "./icons/icon.icns"]
Defensive patterns

Strategy: validation

Validate before calling

// before build: ensure all icon PNGs are standard square ICNS sizes
const SIZES = [16,32,64,128,256,512,1024];
for (const p of cfg.bundle.icon.filter(i => i.endsWith('.png'))) {
  const { width, height } = await imageSize(p);
  if (width !== height || !SIZES.includes(width)) throw new Error(`${p}: ${width}x${height} is not a valid ICNS size`);
}

Type guard

function isValidIcnsSize(w, h) {
  return w === h && [16,32,64,128,256,512,1024].includes(w);
}

Prevention

When it happens

Trigger: Calling create_icns_file with a source PNG whose width/height (after decoding) does not match any standard ICNS icon size (16, 32, 64, 128, 256, 512, 1024 px, incl. @2x variants).

Common situations: Developers drop a non-square icon (e.g. 100x100) or an oddly sized PNG into tauri.conf.json > bundle > icon; icons generated by tools at non-standard sizes (e.g. 300x300) hit this during `tauri build` on macOS.

Related errors


AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18). Data as JSON: /api/errors/c61603f8b00965db. Report an issue: GitHub.

Appendix: source

Thrown at crates/tauri-bundler/src/bundle/macos/icon.rs:57

  let mut family = icns::IconFamily::new();

  fn add_icon_to_family(
    icon: image::DynamicImage,
    density: u32,
    family: &mut icns::IconFamily,
  ) -> io::Result<()> {
    // Try to add this image to the icon family.  Ignore images whose sizes
    // don't map to any ICNS icon type; print warnings and skip images that
    // fail to encode.
    match icns::IconType::from_pixel_size_and_density(icon.width(), icon.height(), density) {
      Some(icon_type) => {
        if !family.has_icon_with_type(icon_type) {
          let icon = make_icns_image(icon)?;
          family.add_icon_with_type(&icon, icon_type)?;
        }
        Ok(())
      }
      None => Err(io::Error::new(
        io::ErrorKind::InvalidData,
        "No matching IconType",
      )),
    }
  }

  let mut images_to_resize: Vec<(image::DynamicImage, u32, u32)> = vec![];
  for icon_path in settings.icon_files() {
    let icon_path = icon_path?;

    if icon_path.extension().is_some_and(|ext| ext == "car") {
      continue;
    }

    let icon = image::open(&icon_path)?;
    let density = if utils::is_retina(&icon_path) { 2 } else { 1 };
    let (w, h) = icon.dimensions();
    let orig_size = min(w, h);

View on GitHub (pinned to 460ec35447)