2013-03-04 50 views
4

我試圖使用AppleScript將斷點添加到當前XCode項目中的選定.m文件。通過AppleScript在Xcode 4中添加文件斷點

現在我被卡住了,因爲AppleScript在嘗試添加文件斷點時總是返回'缺失值'。

我現在的AppleScript看起來像這樣(其中PROJECTNAME明明是我的當前項目的名稱):

tell application "Xcode" 
-- Get the name of the selected document 
set selectedFile to text document 1 whose name ends with (word -1 of (get name of window 1)) 
set nameOfSelectedFile to name of selectedFile 

set fileReference to missing value 
set activeProject to project "PROJECTNAME" 

-- Iterate over the main groups of the project 
tell activeProject 
    repeat with currentGroup in groups 
     set nameOfGroup to name of currentGroup 
     -- Iterate over the file within the main groups 
     repeat with currentFile in file references of currentGroup 
      set nameOfFile to name of currentFile 
      -- If the current iterated file's name equals the file of the nameOfSelectedFile we've got the fileReference 
      if nameOfFile is equal to nameOfSelectedFile then 
       set fileReference to currentFile 
      end if 

     end repeat 
    end repeat 
end tell 

if fileReference is equal to missing value then 
    return "No match found" 
else 
    -- Try to add file breakpoint to the active workspace document 
    set awd to active workspace document 
    tell awd 
     make new file breakpoint with properties {line number:21, file reference:fileReference, automatically continue:true, enabled:true, name:"test", condition:"none", id:"test"} 
    end tell 
end if 
end tell 
+0

加入到討論中,我嘗試了以下並得到相同的錯誤:'用屬性(awd斷點的項目1的屬性)創建新的文件斷點' – atommclain 2013-12-12 23:25:28

回答

0

我認爲,標識和名稱是隻讀屬性,我建議你嘗試刪除這些,然後執行。