6

This question has been asked before and i have looked in all of the other stackoverflow topics for an answer, but i can't resolve the issue.

My app works fine in the simulator for all platforms, but when i run the app on my device i get the error code: Could not load the "image.png" image referenced from a nib in the bundle with identifier "com.bundle.identifier".

Screenshot for message on console

All of my pictures are .PNG files and i have used the storeboard to insert them in an imageView.

Program: Xcode 5

Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177
user3040900
  • 61
  • 1
  • 1
  • 2

9 Answers9

12

If you are using the image name without extension e.g. [UIImage imageNamed:@"myImage"];
then make sure that your image is of .png format, because Xcode will load only .png images without adding extension, otherwise you should use the name with extension [UIImage imageNamed:@"myImage.jpg"]; and should work.

Basheer_CAD
  • 4,908
  • 24
  • 36
  • 2
    I came across this problem when switching my deployment target from iOS 8 to iOS 7. Apparently iOS 8 handles automatically handling .jpg extensions in `+imageNamed:`, but iOS 7 does not – Matt Cooper Dec 04 '14 at 19:55
6

I had the same issue and I resolved it by selecting the check box to add it to app in Target Membership. So, select the image from the library, and then on the File Inspector, add it to the target. It worked for me, hope it works for you as well.

ashNair
  • 105
  • 1
  • 7
4

Delete that image from the project and move it to trash and then try re-adding that image to the project by checking copy items to destination's group folder check box clicked.

This may be the reason for the issue for not loading the image in the device.

Nazik
  • 8,696
  • 27
  • 77
  • 123
3

I resolved this issue by deleting the image named image.png in my storyboard and it worked immediately. This image may also exists in your code or anywhere else.

Nic
  • 12,220
  • 20
  • 77
  • 105
ChenXi
  • 51
  • 4
2

The nib (or ultimately the xib) that is the cause of the warning message is the one that is loaded when the message gets written. You then can look at the controls that use images in the inspector and find one where the image name is "Unknown image" (or perhaps "image.png" in your case). You can then clear this value by setting it to some value and then clearing out the value. Note that with UIButton you'll need to try the four different values of "State Config" (Default, Highlighted, Selected & Disabled) to see where the invalid reference might be hiding.

ThomasW
  • 16,981
  • 4
  • 79
  • 106
2

Removing the reference and adding it again to the project did the job for me! you might need to clean the project.

MQoder
  • 712
  • 8
  • 21
2

I got this problem when I accidentally added another Image set with the same name to Asset Catalog file. I renamed it after I realised the mistake, but it doesn't seem to work.

Removing the file and adding it again solves the problem.

Enrico Susatyo
  • 19,372
  • 18
  • 95
  • 156
1

I found the solution to be a missing file.

Original content:

For all the n00bs out there like me ... The image has to be PNG ...

Matej
  • 9,548
  • 8
  • 49
  • 66
GrandSteph
  • 2,053
  • 1
  • 16
  • 23
-1

Delete the image (by using the Remove Reference option)

Re-Add it and make sure that in the add to targets section your project name is selected. (usually it happens when only yourPojectTests is selected)