2

I have a compass.jpg file that exists in Download folder. Then I dragged this image to my Images.xcassets. I made sure that the image is indeed within the folder by right click the image entry and view folder.

Then, in storyboard, I set my logo image view to this image, and with name compass. It all displays fine in the storyboard.

But, then, I started my app in my iphone, as well as in simulator. It gives me the following error:

Could not load the "compass" image referenced from a nib in the 
bundle with identifier "com.x.Point"

I can't figure out how to solve this problem. Image's folder is indeed inside Images.xcassets folder.

How do I resolve this problem?

Update

I eventually have to make compromise to add the image into the project itself rather than its .imageassets folder.

I actually created a new project and copied and pasted all of my source code there, then .imageasset folder works again! I guess it is not a problem of my project settings. It must have something to do with XCode, I am still unsure of.

donkey
  • 4,285
  • 7
  • 42
  • 68

2 Answers2

0

You need to drag the image outside of the Image.xcassets folder and into your project. The xcassets file is only for splash images and icons.

GuybrushThreepwood
  • 5,598
  • 9
  • 55
  • 113
  • This makes sense, but all other images I put in seems to be recognised. But they are added earlier. Somehow, the `logo` image that I added today is not recognised. My question focuses more on how to get it working, rather than what should be put in there – donkey Jan 20 '15 at 15:01
  • Also it could be the name logo is protected - try naming the file something else. – GuybrushThreepwood Jan 20 '15 at 15:02
  • I tried to rename it, still to no avail. I have edited my post. – donkey Jan 21 '15 at 21:43
  • My only other thought is that the image is saved in a format xCode doesn't like - is it crushed / corrupted / saved with processing effects ? What happens if you try another image with the same name ? – GuybrushThreepwood Jan 22 '15 at 10:28
  • I changed to another image, still same problem. At the moment, I dragged the image file outside of xcassets and use it as usual. It is not my favourite approach, but I will use it for now. – donkey Jan 22 '15 at 18:46
  • Odd. The xcassets is a json file right ? What happens if you view the raw source - anything look odd or missing ? – GuybrushThreepwood Jan 23 '15 at 13:49
  • Actually in one project I have two images with same name, one in the project, and other in the xcassests file, and it loads one from the xcassets file – Frane Poljak Dec 04 '15 at 14:35
0

Have you tried setting the name to compass.jpg? I had a similar problem where the .jpg file from xcassets was not be loaded with the message Could not load the "xxx" image referenced from a nib in the bundle with identifier xxx, although it was correctly shown in the storyboard.

Adding the extension .jpg to the name resulted in the image not shown correctly in the storyboard preview, but loading correctly at runtime.

Klemens Zleptnig
  • 1,698
  • 20
  • 36