Text search though all .xib files in Xcode?

后端 未结 10 483
遥遥无期
遥遥无期 2020-12-22 19:35

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?

相关标签:
10条回答
  • 2020-12-22 20:02

    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.

    0 讨论(0)
  • 2020-12-22 20:05

    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
    
    0 讨论(0)
  • 2020-12-22 20:06

    I may be daft, but using spotlight works great for me on this one.

    0 讨论(0)
  • 2020-12-22 20:06

    grep -i -r --include=*.xib "TextToFindHere" /PathToSearchHere

    response: no matches found: --include=*.xib

    cd /PathToSearchHere
    grep "TextToFindHere" ./ -r | grep ".xib"
    

    this work fine.

    0 讨论(0)
提交回复
热议问题