iOS WidgetKit cannot load certain Image
Asked Answered
R

3

6

I have my images Assets.xcassets, and try to load it in my Widget View. To use images in widget too, I already set target membership for widget extension. But the problem is it cannot load certain images (ex. HalloweenOne, HalloweenTwo, HalloweenThree). The size of every images is under 10kb. (All of the images are loaded well in a app.)

Image("HalloweenOne")
    .resizable()
    .aspectRatio(contentMode: .fit)
    .frame(maxWidth: 50)

enter image description here

Retiarius answered 11/7, 2021 at 14:53 Comment(0)
F
7

I also encountered the same problem. After trying many methods, I solved the problem by changing the "Asset Catalog - Compression" on the right to "GPU Smallest Size".

Flexor answered 6/7, 2022 at 15:15 Comment(0)
P
4

We have investigated this issue. There are a few reasons:

  1. The image should not be in SVG format, so use jpg or png.
  2. The width of the image should not be >= 1000.

If something is wrong, it will break all the elements of the widget.

Penley answered 10/10, 2022 at 10:35 Comment(1)
This fixed it. I simply reduces the image size and it just worked. Thanks!Wigwag
E
1

I'm not sure from where is the value, But the Swift Preview hinted me the following:

    ==================================
    
    |  RemoteHumanReadableError
    |  
    |  ArchivingError: imageTooLarge(size: (256.0, 256.0), maximumSize: (106.8, 106.8))

Encephalomyelitis answered 7/3, 2024 at 7:0 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.