This is a long shot, but has anyone ever tried to automate creating a breakpoint in Xcode? I’d like to be able to use my Stream Deck to create a new logging breakpoint. (I’m not talking about an AppleScript breakpoint in Script Debugger, but an Objective-C or Swift breakpoint in Xcode.) As far as I can see, the Xcode scripting dictionary doesn’t include any support for breakpoints.
I can create a plain breakpoint with a shortcut key, but then I have to right click on it to customize it. I don’t see any way to automate that, but maybe there is something obvious I’m missing?
If you’re not familiar with Xcode, here’s what the process of customizing a breakpoint looks like. First you click in the gutter to create the breakpoint, then you right click:
Then you choose Edit Breakpoint and fill in the dialog.
I would like to automate creating a breakpoint that writes to the log, and automatically continues after evaluating actions. It seems to me that this would be something a lot of developers would want to do, but my google searches turn up nothing.
Yes, the Xcode scripting interface provides no control over breakpoints.
I think this might be possible via UI scripting. You could use the Breakpoints project view, find the breakpoint and summon the Breakpoint Editor via double-click or the Edit Breakpoint contextual menu item. From there you can drive the popover panel.
I was afraid that UI scripting might be the only option. That’s unfortunate, but thanks for replying.
I totally understand - UI scripting is my tactic of last resort.
I had another idea: bypass the Xcode UI. What if you generate the
PROJECT.xcworkspace/xcuserdata/mall.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist file and populate the breakpoints there?
<?xml version="1.0" encoding="UTF-8"?>
uuid = "1685254A-E423-4676-B467-4E2D9B1B3AA6"
type = "0"
version = "2.0">
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
uuid = "3E7D4618-FE78-4945-8E98-0979645967F7"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Shared/PEERRecordingExportActivityProvider.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "47"
endingLineNumber = "47"
landmarkName = "startProgress()"
landmarkType = "7">
ActionExtensionID = "Xcode.BreakpointAction.Log">
message = ""
conveyanceType = "0">
You might have to close and re-open the project to get Xcode to see the changes, but this seems like a more precise way of accomplishing this.
That’s very interesting. I’ve never been aware of that file before.
Without checking, I’m guessing that the 9223372036854775807 is NSNotFound.
I think so. I tried manually editing a breakpoint in BBEdit, and Xcode didn’t notice. If I have to close and re-open the project every time, that’s not going to be a very handy automation. It would be very cool if that structure was exposed thru AppleScript in Xcode 14, but I’m not going to hold my breath.
I’m glad I asked though – I may find some use for directly working with that XML file. Thanks again.