Could not load the image referenced from a nib in the bundle with identifier
Asked Answered
Q

16

16

I had got an iPad application.The ViewContrtoller.xib has got an UIImageView in it. The UIImage of the UIImageView is set through Interface Builder. When I run the application in simulator everything is fine. But when I am trying to run it in iPad the UIImage is not loaded. The message that I am getting is:

HexaPuzzle1.0[3259:207] Could not load the "start.png" image referenced from a nib in the bundle with identifier "com.yourcompany.HexaPuzzle1-0" 2010-12-17 10:57:27.221 HexaPuzzle1.0[3259:207] HexaPuzzle loaded

Any help would be appreciated and will be a great help for me.

Quiche answered 17/12, 2010 at 5:46 Comment(8)
Make sure the image is included in your bundle. If you ran it in the simulator with it, but accidentally removed it before running on the device, the simulator could still have it but the device wouldn't.Lovmilla
@ughoavgfhw: The image is already in the bundle and I haven't removed it.Quiche
Try by remove the old build in the device and install new buildAdlay
@Satya: I had removed old build removed the image and reloaded with new image. Then also the same problem persist.Quiche
I think, you may have given the wrong image name in the code, that means you need to give exact name(case sensitive). iPhone device is case sensitive, but simulator is not.Adlay
@Satya: Not at all. The image name is correct.exact match. No difference in the case.After all image is placed in image view through interfacebuilder. Not by code.I had already checked for this possibility. Thanks for the interest shown by you.Quiche
See this answer https://mcmap.net/q/323297/-could-not-load-quot-my-icon-png-quot-image-referenced-from-a-nib-iphoneDag
Here is another possible solution for iOS 8 - https://mcmap.net/q/319779/-could-not-load-the-image-referenced-from-a-nib-in-the-bundle-running-on-deviceSaimon
Q
25

The issue has been rectified. Problem was with the image format. When the image has been edited and saved as PNG-24 everything goes fine. The application now runs smoothly in simulator and device.

Thanks for all friends who suggested a solution and tried to helped me.

Regards, Rupesh R Menon

Quiche answered 21/12, 2010 at 5:12 Comment(5)
I was having the same problem and this worked for me. Apparently something went wrong the first time I saved the png. I resaved it to a different filename and then renamed it. It is working now. Thanks!Readership
The problem for me I don't have a image file with that name. And I don't use that file in my nib file at all. How can I find which file is using this image file?Indoaryan
In my case, the problem was that the @2x image had a diferente name: a non-capitalized letter.Anthurium
I've put the jpg image to the Images.xcassets. And it worked in simulator but not on the device. Does it mean that iOS doesn't handle jpg images ?Macrography
I've solved it editing all my JPG images and saving them in PNG-24 but I'm sure that it have to be any way to load JPG images. In this Google Group some people say that is enough to add the .jpg extension in the Interface Buider and in Images.xcassets but it didn't work for me...Gemoets
M
12

I know it's very late, but this is a solution that also works in Xcode 5, and therefore likely to be useful to people who have this problem in the future.

I have seen a lot of questions like this on the web but none of them seems to have one clear answer. This is, as far as I know, the solution for this problem:

  • Go to the image in Xcode (no need to re-add or re-generate the image)
  • click "show the file inspector"
  • Make sure the checkbox in the category "Target Membership" is checked. the test check box does not have to be checked to make your app load the image.

The target membership tab looks like this:

enter image description here

if this is already the case, you are working with a broken or damaged file. to rule this out, check if another app (like photoshop) can open your image.

This should do it, hope it helps!

Massarelli answered 5/7, 2013 at 11:1 Comment(5)
@Imagine digital i click on show in inspector the image is not opened please tell me the solutionBoreal
Make sure the image is selected in the navigator when you click the "show file inspector" tab. once you have clicked that tab, make sure you check the checkbox named "Target Membership"Massarelli
There is no "Target Membership" category in the inspector when I have an image selected.Mexico
Thanks @Imaginedigital. My images are in one of those pesky blue folders. Not sure if that has anything to do with the images not loading for me.Mexico
You may want to select the blue folder and make sure the "Target Membership" is selected for that. If not, try to add the images separately instead of the entire folder.Massarelli
P
5

When dragging your start.png file into your project, did you check this option?

alt text

Perlis answered 17/12, 2010 at 6:3 Comment(2)
Hi, Thanks for the interest taken. You mean to add to the image to target? It's already there.Quiche
This has already done. Image is already copied to destination group's folder and it is also there in target. I think some other issue. Any way thanks for your suggestion.Quiche
C
5

I was getting this error in the simulator after upgrading to Xcode 7 / iOS 9 and opening an existing project. The image was present and named correctly, within an XCAssets package.

Turns out the problem was with a parameter within the XCAssets package.

Changing Render As from Default to Original Image solved the problem:

enter image description here

Columbarium answered 20/9, 2015 at 14:5 Comment(3)
I had the same issue, but I'm not sure what is the root cause. Do you know why "Default" doesn't work?Barragan
No @tsr, I haven't had chance to check yet. I did notice that some "Default" images in the project already weren't affected, but I haven't spotted the pattern yet.Columbarium
Solved the problem. ;)Trinitrobenzene
D
3

I've had the same problem before. The png file format is not right. Try re-generate the png image file and the problem will be solved.

Darcee answered 4/12, 2012 at 13:30 Comment(0)
C
1

None of the above worked for me, and the message I got was "could not load the "(null)" image referenced... which means I could not look for the image. Very frustrating. In the end it became a trial and error exercise of going through every xib and storyboard looking for potential conflicts. I finally found it - I had specified a "Selected Image" for a tab bar item which was not needed. As soon as I got rid of that the problem went away.

Caracul answered 21/1, 2015 at 3:58 Comment(0)
S
0

None of these things work for me. I created a new folder in the projects where I placed the pictures. That worked for me.

Subir answered 15/2, 2013 at 21:48 Comment(0)
O
0

This problem was fixed when I changed "add folder reference..." to "add group..." when I import the images to my project. I'd prefer to have folders with live updating, but at least it works now.

Oaks answered 3/4, 2013 at 1:50 Comment(0)
B
0

Had an image on a XIB (which is replaced by the correct one in code). After finishing this XIB, I renamed the images. So XIB was now referencing a non-existent image.

Bothersome answered 2/9, 2013 at 16:59 Comment(0)
N
0

There is also another potential cause of this problem: If you upgraded to XCode 5 and use both the image asset catalog and "normal" images copied to your project (like you did prior XCode 5). If you then have images with identical names (e.g. "dog.png" and a image set called "dog") it might work in your storyboard and in the simulator, but you'll get this message when run on a real device (where the image will not be shown).

Nightfall answered 13/1, 2014 at 16:32 Comment(0)
U
0

Try moving the images directly to the Resources directory (not in a sub folder)

Uttica answered 6/6, 2014 at 10:0 Comment(0)
D
0

Make sure the resource isn't too big to be handle.

Distasteful answered 27/3, 2015 at 20:48 Comment(0)
H
0

If you get the error message with the name of the picture, you can search it inside your project and xCode will display immediately the UIImageView with the wrong picture inside UIStoryboard:

enter image description here

Hospitium answered 9/4, 2015 at 12:26 Comment(0)
S
0

Make sure it is included in your Target Membership

  1. Select your "Images.xcassets" file in the file Inspector
  2. Open File Inspector (cmd + opt + 1)
  3. Select your target membership (Usually 1st line)
Selfreliant answered 28/9, 2015 at 11:6 Comment(0)
T
0

I had the same problem, but the cause was very different. I was using image sets in the Asset Catalog that varied based on the device idiom: iPad or iPhone.

The framework target they were being added to had been accidentally marked as as having a deployment device type of iPhone, so the images weren't showing up on iPads - they weren't even being copied into the .car file in the framework.

Setting the deployment device type to Universal, as it should have been, solved the problem.

Tippets answered 26/2, 2018 at 23:40 Comment(0)
E
0

For some reason I was getting error until I put the image in the Assets.xcassets

Endear answered 22/12, 2018 at 9:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.