Text search though all .xib files in Xcode?

后端 未结 10 493
遥遥无期
遥遥无期 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: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
    

提交回复
热议问题