Could not load the image referenced from a nib in the bundle running on device

IphoneObjective CXcode

Iphone Problem Overview


> SplitView[1290:307] Could not load the "canary04.png" image referenced from a nib in the bundle with identifier "xx.co.mycompany.ipad.SplitView"

I only get the error when running on the device. There are no problems running in simulator.

I am using the image directly in interface builder with an UIImageView.

EDIT: I have added a different new image to a different nib and that works no problems.

Anyone have any ideas?

Iphone Solutions


Solution 1 - Iphone

It might not be added to your Target and in XCode 4 you can do it like this:

  • In your Project View, click your project name
  • Select your target and select "Build Phases" tab
  • Drag your image file into your "Copy Bundle Resources" section

That fixed it for me.

Solution 2 - Iphone

The filesystem on iOS devices is case sensitive, so it's quite possibly a case issue. (Mac OS X is generally case in-sensitive, hence you've not seen this issue in the simulator.)

As such, check that you're using the same case in the code as the filename itself.

Solution 3 - Iphone

Do you have the image in a referenced folder in XCode (blue folder)? If so you have to include the folder name in the image path, something like "Images/canary04.png"

Solution 4 - Iphone

The easy way

1 Simply do a grep in command shell to find the string of the referenced image:

grep -R 'canary04.png' YourMainDirectoryFolder/*

2 It will give you (for example) an output like this:

YourProject/en.lproj/YourViewController.xib: 
          
<textField borderStyle="roundedRect" background="canary04.png" id="19">

3 You now know which nib file and which element it is. Just go in the file and remove the reference.

Solution 5 - Iphone

  1. Delete the blue folder where the image is.
  2. Import again and select "Copy items if needed".
  3. Select "Create Groups" NOT folders

Solution 6 - Iphone

Save image as PNG-24. It works for me

Solution 7 - Iphone

You can do this to check it from your storyboard, or nib. Open it as Source Code:

enter image description here

Then "Find" the image name in it, see if it exists but already invalid in your project, probably you have deleted or changed its name, and now it doesn't seem valid.

enter image description here

Solution 8 - Iphone

Have you included the file in the target? Right-click on your Target in Xcode, select Get Info and choose the "Targets" group along the top. Make sure your intended target(s) are checked.

Good Luck.

EDIT: The text above should have read Right-click the file (canary04.png) in Xcocde and select Get Info...

Sorry for the typo.

Solution 9 - Iphone

I had this problem when I upgraded to Xcode 4.4.1. I found that although I had deleted the images (and corresponding buttons, etc.) in the storyboards, there was still mention of them in my storyboard files (in a tabBarItems field). I manually commented them out (), Product -> Clean, and I didn't get the errors any more.

I knew there must be bogus references in the storyboard as I had previously deleted my TabBar and the current App worked without problems, just with annoying messages in the console.

Solution 10 - Iphone

I had the same issue. try to

  • clean
  • build and run

it worked with me

Solution 11 - Iphone

In my case, it was because Photoshop wasn't saving my files correctly. In the file save dialog I was clicking on myfile.png in an attempt to overwrite that file, and it was saving the file with a png extension, but in photoshop format.

I had to make sure to actually change the file format to PNG before clicking on the file I wanted to overwrite, thus saving in actual png file, thus being readable by iOS. Interestingly, interface builder showed my psd-as-png files just fine.

More generically, make sure your file is, in fact, in the format you think it is and that iOS is therefore expecting.

Solution 12 - Iphone

Solution 1 :

In my case I had copied folder containing images and even checked "Destination : copy items if needed". However it has not been added to "Copy Bundle Resources" of "Build Phases".

You can add images as follows :

  1. Select Targets
  2. Select "Build Phases" tab
  3. Select "Copy Bundle Resources"
  4. Click on "+" (Plus) button just beneath it
  5. Locate images and add it

Screenshot for solution 1

Solution 2 :

Delete images by selecting "Move to thrash". Again add images in your project with "Destination : copy items if needed" checked.

Note : Make sure that you add images in Assets.xcassets folder and not outside it.

Solution 13 - Iphone

I was getting this error too. I will describe my scenario:

I have a subdirectory "img" which has some png's in it.
One of these png is "ic_timeprogress_000.png"

In the storyboard (visual designer) I had an imageView and the image was set to "ic_timeprogress_000.png" (not programatically). The designer showed the imageView correctly:

imageView in subdirectory

Although when running the app, the error was thrown.

So in the storyboard I changed (I insist: not programatically) from "ic_timeprogress_000.png" to "img/ic_timeprogress_000.png", which lead to not showing correctly the image in the designer but showing correctly when running (no error)

imageView in subdirectory

Although I alter imageView.image programatically, so this "initial image" isn't ever used.

Solution 14 - Iphone

Check to make sure that canary04.png exists in your project, and that it was not deleted.

Solution 15 - Iphone

My problem was that I saved the image as .jpg and changed the name to .png (was still in jpg format). It worked with simulator

Solution 16 - Iphone

Check your image name. If it contains some spaces then image will show while running in simulator but not in the device. While running it checks Case sensitive name etc.

Solution 17 - Iphone

I had a different problem in iOS 8. In my case the problem was that I selected Device Specific for the image set, and then selected iPad. Changing this back to Universal fixed the problem.

This setting can be found in the images.xcassets file, in the third column show the attributes inspector for the image set.

In this case the images wont be displayed in the storyboard or NIB file even if you have added them to images.xcassets. They also wont show in the simulator or device.

Solution 18 - Iphone

I've encountered this issue when I was trying to set image of an imageView on Interface Builder (.xib) file.

(I was using Image Assets)

I've had 2 images with theImage.jpeg and [email protected] Interface Builder could be able to display true images at compile time with these jpg / jpeg formats. But I've got this error in the runtime:

Could not load the "theImage" image referenced from a nib in the bundle with identifier "org.etc.etc"

Then I changed my image files formats to .png and it worked!

Try this solution too if you have different formats for images you try to set.

Solution 19 - Iphone

I also met the problem that jpeg files cannot be loaded successfully, however I solved it without changing them to png format: for example, if you have an image named "bg.jpg", don't use "bg" in storyboard (this name is listed in the dropdown selection list), instead you should explicitly write "bg.jpg" in the name field.

For programming based image view, I guess using .jpg extension like [UIImage imageNamed:@"xx.jpg"] should also work (I did't test though).

Solution 20 - Iphone

Try cleaning the project and make sure the info.plist matches the xx.co.mycompany.ipad.SplitView

Solution 21 - Iphone

Check the image name. Then check to see if you can open the image itself in paint or photoshop. If the image was created in photoshop and there were layers sometimes there is some conflict with the .png

Solution 22 - Iphone

I had the same issue, if your images are inside sub-folders, you need to choose "Create groups for subfolders" Option when you copy the resources.

Solution 23 - Iphone

I have this problem with Xcode 5, and it seems "Combine high resolution artwork" is the culprit. I opened the app bundle, and all the images were *.tiff, which caused the image to "not be found" :S

FIX:

Open project settings, and search in the top for "combine". Change that setting to NO.

enter image description here

For some reason, everyone is missing this essential fix.

Solution 24 - Iphone

In my case all images where displaying fine on devices with >iOS 7 but not with iOS 6.1. The solution was that iOS7 is case sensitive but iOS 6.1 wasn't for me. I had images named like "myImageName" and also named "myimagename" witch leads my old iPhone 3 to be unable to display these images.
So renaming them solved it.

Solution 25 - Iphone

Tried each and every answer here and nothing, so here's another glitch, your icon name cannot have dots (.) because if it does (and Xcode allows you to do that!) while the icons show well in storyboard, they won't load either in the simulator or the device.

Solution 26 - Iphone

Maybe after you set the button's image, you changed the image's name.

Solution 27 - Iphone

2015 - Still having this problem. I was referencing an image that no longer existed in one of tabbed buttons.

Solution: Simply inspect all your buttons, UIImage etc. and make sure that the image that you are referencing actually exists within your project.

Solution 28 - Iphone

I got this problem when I accidentally added another Image set 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.

Solution 29 - Iphone

what worked for me is making sure the file's owner in interface builder has a "view" outlet.

From IB, select file's owner from "Placeholders", then in "Connections Inspector" make sure the view outlet in connected to the main view of current XIB.

This happened because i removed the main view at some point and forgot to reconnect my new view.

Hope it helps somebody else.

Solution 30 - Iphone

In my case, the issue was the image format. They were 'jpg' files, while Xcode was expecting 'png' files. Changing the file format fixed the issue.

Solution 31 - Iphone

i also faced same problem because i edited image in photoshop and saved as a psd format make sure you save your photoshoped images in jpg or png format in my case that was the problem hope it helps thanks

Solution 32 - Iphone

JPEG format does gives this error in release mode in iOS. This might happens while, XCode optimizes the code for release. Try replacing the image with JPEG and it will solve the problem.

Solution 33 - Iphone

My trouble was none of the above. I put the iconFolder in Xcode project's folder.

When I imported it, selected "Copy items if needed" and "Create Groups".

It worked for me.

Solution 34 - Iphone

For whatever reason, adding the file extension to the end of the image title is what solved it for me.

it was referencing "canary04" bc thats what I titled the image, but once I changed the image title to the title of the image itself (canary04.png) it was solved.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTheLearnerView Question on Stackoverflow
Solution 1 - IphonePeter TheillView Answer on Stackoverflow
Solution 2 - IphoneJohn ParkerView Answer on Stackoverflow
Solution 3 - IphoneKendall Helmstetter GelnerView Answer on Stackoverflow
Solution 4 - IphoneMickView Answer on Stackoverflow
Solution 5 - IphonesbastidasrView Answer on Stackoverflow
Solution 6 - IphoneMannView Answer on Stackoverflow
Solution 7 - IphoneTomView Answer on Stackoverflow
Solution 8 - IphoneMystikSpiralView Answer on Stackoverflow
Solution 9 - IphoneBeauView Answer on Stackoverflow
Solution 10 - IphoneAhmadView Answer on Stackoverflow
Solution 11 - IphoneNoah DyerView Answer on Stackoverflow
Solution 12 - IphoneJayprakash DubeyView Answer on Stackoverflow
Solution 13 - IphonesportsView Answer on Stackoverflow
Solution 14 - IphoneWrightsCSView Answer on Stackoverflow
Solution 15 - IphonetonisivesView Answer on Stackoverflow
Solution 16 - IphoneArunView Answer on Stackoverflow
Solution 17 - IphoneReefwingView Answer on Stackoverflow
Solution 18 - IphoneersentekinView Answer on Stackoverflow
Solution 19 - IphoneYingpei ZengView Answer on Stackoverflow
Solution 20 - IphoneMaxView Answer on Stackoverflow
Solution 21 - IphoneMattView Answer on Stackoverflow
Solution 22 - IphoneVeeruView Answer on Stackoverflow
Solution 23 - IphoneMazyodView Answer on Stackoverflow
Solution 24 - IphoneYedyView Answer on Stackoverflow
Solution 25 - IphonePedro BorgesView Answer on Stackoverflow
Solution 26 - Iphonebackslash112View Answer on Stackoverflow
Solution 27 - IphoneRonaldoh1View Answer on Stackoverflow
Solution 28 - IphoneEnrico SusatyoView Answer on Stackoverflow
Solution 29 - Iphonecarlos16196View Answer on Stackoverflow
Solution 30 - IphoneNRRView Answer on Stackoverflow
Solution 31 - IphoneMehul DView Answer on Stackoverflow
Solution 32 - Iphonegunjot singhView Answer on Stackoverflow
Solution 33 - IphoneAlvin GeorgeView Answer on Stackoverflow
Solution 34 - IphoneFelecia GenetView Answer on Stackoverflow