Image not rendering on some devices

Hi, new developer here.

I have an issue where an image I have on app is not showing up on some devices.

The image is: Resources/Assets/logo:

I am using it in my app like:

        ZStack {
            Color.white
                .ignoresSafeArea()
            
            VStack {
                Spacer()
                
              Image("logo")
                
                Spacer()
                
                Text(dateString)
                    .font(.custom("LinLibertine", size: 17))
                    .fontWeight(.bold)
                    .tracking(5)
                    .padding(.bottom, 50)
            }
        }

The image appears fine on all simulators. And also on my real device iPad with A14. But when I run it on iPhone 8 or iPad Air M4, it shows empty space in place of image.

I tried many different options like:

Image("logo")
.renderingMode(.original)
.resizable()
.scaledToFit()
frame(width: 300)
.background(Color.red.opacity(0.3))

But nothing works. What can be the issue?

Hello @thisisjaymehta,

Welcome to SwiftUI development! 🥳

The first thing I would look at is the Attributes menu, located in the Inspector area (the sidebar on the right of Xcode). You can also quickly open this tab by pressing ⌥ ⌘ 4.

In that menu you will notice options for devices, appearances, sizes and more. In your screenshot, it appears you have the Scales set to "Single Scale". You can try switching this to "Individual Scale" and add different scales which are configured to show on different devices.

You can find more information about how to do that here Fitting images into available space

If not, try appearances and see if it's a light/dark mode issue. It looks like you already did some troubleshooting by setting a solid white color background. A great tip you can use to check both color schemes easily is by using this toggle at the bottom of the canvas in Xcode, which will show both the light and dark move preview in Canvas.

For more information on Xcodes canvas see Previewing your app’s interface in Xcode

Lastly, you can attach a project with the same image in this thread, make sure you remove any code that's not needed to reproduce the issue, and I'd be more than happy to take a look. If you do so, please list the device names+software version you are running, as well as Xcode version.

Let me know if this helps!  Travis Trotto - DTS Engineer

Hi Travis,

Thanks for the reply.

I actually found the issue. Problem was arising due to the assets file being in "Development Assets" in Build Settings. So Image was not displaying in devices where I installed the app from TestFlight.

Image not rendering on some devices
 
 
Q