Add file breakpoint in Xcode 4 via Applescript

ぃ、小莉子 提交于 2019-12-10 17:18:16

问题


I'm trying to add a breakpoint to the selected .m file in my current XCode project using AppleScript.

Right now I'm stuck since AppleScript keeps returning 'missing value' when trying to add a file breakpoint.

My current AppleScript looks like this (where PROJECTNAME obviously is the name of my current project) :

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

回答1:


I believe that id and name are read only properties, I suggest you try to remove those and then execute.



来源:https://stackoverflow.com/questions/15199689/add-file-breakpoint-in-xcode-4-via-applescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!