80

when I load my application it shows a warning message that

"Could not load the "" image referenced from a nib in the bundle with identifier "

I searched and confirmed all my images. But it still shows that warning.

4
  • I've done all the solutions related to this, but still it shows the warning. plzzz help
    – Hilaj S L
    Jul 3, 2015 at 5:15
  • 1
    I think you set one image to UIImageView but that image is not exists in your bundle, please check your xib Jul 3, 2015 at 5:15
  • Are you using images in tabbar or selected mode? Which Xcode you are using?
    – Hindu
    Jul 3, 2015 at 5:26
  • Getting the same error, but for any/all images used on a specific scene (including images that work fine on different scenes): stackoverflow.com/questions/71925893/…
    – Mercutio
    Apr 19, 2022 at 13:36

25 Answers 25

53
  1. Select your image(s) in Project Navigator.
  2. Open the File Inspector.
  3. Make sure you have the target selected.

Add your image to the target

5
  • Thank you!!!!!!!! Did Everything, up to & including the kitchen sink, but finally adding the images, image-by-image via "*.xcodeproj" -> "Build Phases" -> "Copy Bundle Resources" Thanks to xcode... wasted 4 hours on this little problem... Never had this before using makefile... crazy... This is exactly WHY people hate gui based build tools....!
    – user2052717
    Apr 2, 2018 at 7:08
  • You are awesome bosssssss Apr 16, 2018 at 20:20
  • A very teeny-weeny problem that can waste several hours, if not for this answer. Thank you...
    – Abhishek
    Jun 3, 2018 at 8:12
  • Help! I still get this same error even though I've tried all the "fixes" on this page. My file is called "landscape.png" and I'm using Xcode 10.
    – Kevin
    Dec 31, 2018 at 3:59
  • @Kevin Try deleting landscape.png from the project and then renaming it. Then drag it into the project, and make sure you check the "copy items if needed" box. Then after it's in the project, make sure the box is checked for "Target Membership" as shown in the answer above. Jan 1, 2019 at 1:40
45

I had the same issue when I Refactor to Storyboard. Apparently the Asset catalog does not transfer the image reference. To fix, see below:

You would notice that your ImageViews is empty from reference.

Image Views

1 - Click on the ImageView

Click the Image View

2 Go to the Utilities bar where you would see you asset image is unknown

Unknow Image

3 - Change it back to you image asset

Choose your image again

This should fix your error. Hope this helps!

0
19

There might be many reasons of this error. To fix this issue you can just follow below given step:

  1. Go to product menu of the Xcode, select clean.
  2. If still you are getting the error, then remove the images from your project and again add the images to your project.
  3. while adding image into the project, make sure that you have selected the Project name inside the "Add to targets". And also enable the "Copy items if needed".

Please Refer below image for better understanding:

First Image convey that while uploading image the TestTests is enable under **Add to targets**

Due to the above process we are getting error, as we can see in the console of Xcode

Image 3rd show the correct way of uploading image/file into the project

The final image 4th show the output without any error/warning

1
  • Removing all images as the second option potentially sounds like a ton of work and it is not exactly a solution. Just check your imageViews and one or more of them will have say "Unknown Image".
    – Zia
    Oct 31, 2016 at 21:44
9

Just select the image in Xcode and in right side, File inspector, under 'Target Membership' make sure your project is selected. Another thing you can do is delete and re insert your image and make sure 'Copy items if needed' is selected and 'Add to targets' your project is selected.

1
  • For me it was important to delete the whole folder in den image.assets. Not just delete the images. Strange error...
    – kuzdu
    Apr 16, 2016 at 8:01
7
  1. Click on the image file in your Xcode navigator.
  2. Once selected, go to the right side bar (of XCODE) which is utilities and under file inspector, scroll to target membership and select your project target file.
  3. Then build and run the project again.
5

Xcode9 beta2 release note:

Jpeg assets in asset catalogs are not found on iOS 10 or earlier for apps built with Xcode 9. APIcalls for accessing the image such as UIImage.imageNamed: return nil. (32524123)

Workaround: Use png resources or limit app testing to devices running iOS 11 or later.

Xcode9 beta3 release note:

Jpeg assets in asset catalogs are found on iOS 10 or earlier for apps built with Xcode 9.(32524123)

1
  • 1
    I am seeing this issue with Xcode 8.3.3 / iOS 10. Switching to PNGs clears the issue, but adds size.
    – Ben Flynn
    Jul 6, 2017 at 20:29
5

For those that are getting this error while developing a cocoapod

I was trying to use an image from my pod's bundle, thats inside a .xcassets file, in the storyboard. It would show fine in the storyboard but when i ran the app it would crash saying it cant find the resource.

I changed my podspec to include s.resources as well as s.resource_bundles

s.resource_bundles = {
  'SDKRes' => ['SDK/Assets/*']
}

s.resources = ['SDK/Assets/*.{xcassets}']

Then it was able to load the resource properly from the storyboard

1
  • Wow this actually fixed an issue that just started for me with iOS 15 SDK on iOS 15 devices - images were not being loaded from a custom pod I have. For me, I use the following: 'PROJECT_NAME/Classes/**/*.{storyboard,xib,xcassets,json,imageset,png,strings}' Jan 12, 2022 at 16:21
4

You can try opening your storyboard or nib as Source Code and 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.

1
  • For a specific find: image="name" or image name="name". I just had this error for an image named "first" and storyboard code had a lot of firstAttribute,.. :p May 10, 2019 at 9:45
3

I have just updated to XCode 9 and it started giving me this issue. I created a new Image Set in the Assets section and added the images I wanted to this, then re-added them to my tab bar images with custom names and it worked fine. Hope this helps!

2

PROBLEM
This happened to me seemingly out of the blue on a tab bar controller with icons for each tab. The storyboard was still showing my image icons and the assets existed with the expected names.

MY FIX
Select the tab bar icons in their respective view controller and reassign the image like you did the first time.

1

This happened to me as well. I was doing everything right when adding the image but for some reason it was not working. I had to click on the image again once added, and then on the right toolbar under "Target Membership" I noticed my project was not selected even though I was selecting it when adding the image. I selected it here and everything worked fine.

1

I got the same error message (in XCode 8), even though the app ran fine (in the simulator and on the device).

I found the problem: In my storyboard, using the document outline pane, I clicked through every single UIImage, and looking at the attributes inspector for each UIImage - in the Image View section - found that one UIImage had a blank file name (instead of the .png file name containing the image). Reselecting the .png file name from the dropdown box fixed the error message.

1
  • Thanks, this worked for me. I went through all the UIImageViews and found one that was showing an image but the Image field was empty. Added it and now it works fine. Oct 1, 2017 at 18:01
1

I have fetching same issue in xcode 9.

just tick on target membership

enter image description here

1

I pulled my hair out over this issue for hours and none of the solutions in this thread worked. The problem, in the end, was that the Xcode project files were stored on a Google Drive file stream. As soon as I moved it to the local drive or iCloud it worked fine.

1

My case was a bit different. I was using an old IBDesignable element which had some property of setting an image directly from the storyboard. Since that element was old, hidden and unused the images it had were not present in my assets folder.

Now Xcode won't be able to search this image since it is not in the project anymore. But if you search in the finder, inside your project, you'll find the XIB/Storyboard in which it is mentioned. From there you can find it manually by opening that XIB or Storyboard as source code and search. Once found either replace them with a new image or remove the unused element.

1

Look into storyboard file you'll see a question mark icon on any of the imageView (as shown in screenshot below) or UIButton image.
Just correct it and the warning will be gone.

invalid image in imageView

Hope this helps

0
0

My guess is that you have an image in the Project Setting->Build Phases->Copy Bundle Resources which loses its reference and appears in Red text color. Remove this image from there and re-add.

This happens often due to relocate the image file after adding into project where image was added as a reference instead of a copy.

May be this can fix your issue.

0
0

Urughhh. I tried to fix this with all the above solutions, but nothing worked. What finally worked was:

  1. Delete image from your project and select Move to Trash
  2. Clean project
  3. Close and restart XCode
  4. Rename your image filename so something other than the previous name
  5. Add new image to your project
0

I was facing the same problem, I solve it by deleting folder and create again and past all images then add reference again.

0

Based on what @hstdt posted above, it made me think I should check that my image is a filetype that doesn't have any bugs related to it. (https://stackoverflow.com/a/44558948/6804257)

I was using a .gif. I got rid of that image and instead used a .png. Now it works.

0

Had the same issue and none of these answers worked for me. Instead I restarted the mac and iPhone I was working with and then everything started to work fine again. 🤷‍♂️

0

My case is difference. I have more one assets folder. So I added to the wrong one. Just remove and add to the right.

0

In my case,removing and adding the assets folder from the target fixed the issue.

0

Xib sets a wrong name for folder reference images. For example I have the folder like Menu->icon.png. Xib sets the "icon" name for the image. It should be "Menu/icon". So do no set images in xibs if you use a folder reference images.

0

I was having same issue as we have framework that to be build and attach to main project as Third party libraries.

The problem here is image is not found in bundle as yo have to provide path. Below code works for me.

Objective C:

NSBundle *frameworkBundle = [NSBundle bundleWithIdentifier:@"your framework name"]; UIImage *image = [UIImage imageNamed:@"IMG_AboutUS" inBundle:frameworkBundle compatibleWithTraitCollection:nil]; _imgAboutUs.image = image;

Swift:

if let frameworkBundle = Bundle(identifier: "your framework name"){ let image = UIImage(named: "IMG_AboutUS", in: frameworkBundle, compatibleWith: nil) _imgAboutUs.image = image }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.