2014-05-15 60 views
2

我想要打开一个Xcode项目并使用applescript在项目导航器中选择Xcode项目(.xcodeproj)。 我尝试了以下Finder的代码片段,并且Iam能够选择该文件。使用AppleScript在Xcode中选择文件

tell application "Finder" to select file "README.txt" of folder "Image" of folder "Downloads" of home 

我愿做相同的Xcode.I尝试下面的代码片段,但我不能在Xcode项目选择文件navigator.How在Xcode

选择使用 applescript文件
tell application "Xcode" 
open file "Users:xxxxx:Downloads:Project1:Project1.xcodeproj" 
    tell application "System Events" to tell process "Xcode" 
    select file "README.txt" of folder "Project1" of folder "Downloads" of home 
    end tell 
end tell 

tell application "Xcode" to select file "README.txt" of folder "Project1" of folder "Downloads" of home 

回答

0

让Xcode打开单个文件。然后您可以更新导航器窗格。这是代码(您可能需要调整文件路径和延迟间隔):

tell application "Xcode" 
    activate 
    -- open project 
    open file "Users:xxxxxx:Downloads:Project1:" 
    delay 0.2 
    -- open individual file 
    open file "Users:xxxxxx:Downloads:Project1:Project1:README.txt" 
end tell 
delay 0.1 
tell application "System Events" 
    tell process "Xcode" 
     -- Move focus to next area, the individual file 
     keystroke "`" using {command down, option down} 
     delay 0.1 
     -- Reveal in Project Navigator 
     keystroke "j" using {command down, shift down} 
    end tell 
end tell 
相关问题