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.
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.
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.
1 - Click on the ImageView
2 Go to the Utilities bar where you would see you asset image is
unknown
3 - Change it back to you image asset
This should fix your error. Hope this helps!
There might be many reasons of this error. To fix this issue you can just follow below given step:
Please Refer below image for better understanding:
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.
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)
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
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.
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
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!
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.
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.
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.
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.
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.
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.
Hope this helps
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.
Urughhh. I tried to fix this with all the above solutions, but nothing worked. What finally worked was:
I was facing the same problem, I solve it by deleting folder and create again and past all images then add reference again.
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.
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. 🤷♂️
My case is difference. I have more one assets folder. So I added to the wrong one. Just remove and add to the right.
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.
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 }