Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to know which xib file uses the image?

While running my project, I've got this error message.

Could not load the "bs_back_light.png" image referenced from a nib in the bundle with identifier "com.xxxxxxx.new"

I don't use the image file anymore, so I want to delete the image referencing in xib file. However, the project has a lot of xib files, and it is really hard to find xib file which references the image. If it is source file, I would use Find in Workspace(Shift + Command + F), but it doesn't search xib files.

How to search the image referencing from xib(nib) files?

I'm using Xcode Version 4.3.3 (4E3002)

like image 903
Joey Avatar asked Jul 26 '12 09:07

Joey


2 Answers

I had the same problem and I resolved with some console commands. Open Terminal on your Mac and run this command:

grep -i -r --include=*.xib "bs_back_light.png" /your/project/path

It will search in the path "/your/project/path" and will print the complete path of all files xib that use the image "bs_back_light.png".

Hope this will help you!

like image 103
Marco Pace Avatar answered Sep 22 '22 22:09

Marco Pace


I wrote a bash function based on Marco's answer so I wouldn't have to refer back to this post all the time. Just throw it in your bash profile, and you'll be able to run it from the command line in your project directory like "grep_xib UIButton", which would search all your *.xib files for instances of "UIButton". Just thought I'd share in case anyone else needed this.

function grep_xib {
    grep -i -r --include=*.xib "$1" .
}
like image 31
Jacob Avatar answered Sep 23 '22 22:09

Jacob