This seems like such a basic task, but I\'m stumped.
How, in Xcode, do you execute a textual search though (the XML contents of) all the .xib files in a project?
What I do is run grep in terminal:
grep -i -r --include=*.xib "TextToFindHere" /PathToSearchHere
Xcode doesn't seem to have an option to search xib files and my attempts to get Spotlight to look at them have been unsuccessful.
This works if you use as service....
on run {input, parameters}
display dialog "XIB Search Text" default answer ""
set searchtext to text returned of result
if (length of searchtext) is greater than 0 then
tell application "Xcode" to set theProjectPath to (the project directory of front project)
tell application "Terminal"
set newWin to do script "cd " & theProjectPath & "; " & "rm " & theProjectPath & "/searchXIB.txt 2> /dev/null ; grep -i -r --include=*.xib " & searchtext & " . > searchXIB.txt ; exit"
activate
repeat while (exists newWin)
delay 1
end repeat
tell application "Xcode"
set doc to open theProjectPath & "/searchXIB.txt"
activate
end tell
tell application "System Events"
keystroke "f" using {command down}
keystroke searchtext
end tell
end tell
end if
return input
end run
I may be daft, but using spotlight works great for me on this one.
grep -i -r --include=*.xib "TextToFindHere" /PathToSearchHere
response: no matches found: --include=*.xib
cd /PathToSearchHere
grep "TextToFindHere" ./ -r | grep ".xib"
this work fine.