Skip to content

Commit 855b5aa

Browse files
EvanBaconclaude
andcommitted
Add XCSharedData support for breakpoints and workspace settings
Implements unified access to xcshareddata directories containing: - Breakpoints (Breakpoints_v2.xcbkptlist) - file, symbolic, exception breakpoints - Workspace settings (WorkspaceSettings.xcsettings) - build system, derived data, previews - Integration with existing scheme support New modules: - src/breakpoints/ - XML parser/writer for breakpoint lists - src/settings/ - Plist parser/writer for workspace settings - src/api/XCSharedData.ts - High-level API unifying schemes, breakpoints, settings Adds getSharedData() method to XcodeProject and XCWorkspace for easy access. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent bd6455d commit 855b5aa

19 files changed

Lines changed: 2116 additions & 5 deletions

README.md

Lines changed: 109 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,111 @@ Workspace file references use location specifiers:
277277
- `container:path` - Absolute container reference (rare)
278278
- `absolute:path` - Absolute file path
279279

280+
## XCSharedData Support
281+
282+
Access and manipulate shared data directories (`xcshareddata`) which contain schemes, breakpoints, and workspace settings that are intended for version control.
283+
284+
### High-level API
285+
286+
```ts
287+
import { XcodeProject, XCSharedData } from "@bacons/xcode";
288+
289+
// Get shared data from a project
290+
const project = XcodeProject.open("/path/to/project.pbxproj");
291+
const sharedData = project.getSharedData();
292+
293+
// Access schemes
294+
const schemes = sharedData.getSchemes();
295+
const appScheme = sharedData.getScheme("App");
296+
297+
// Access breakpoints
298+
if (sharedData.breakpoints) {
299+
console.log(sharedData.breakpoints.breakpoints?.length);
300+
}
301+
302+
// Access workspace settings
303+
if (sharedData.workspaceSettings) {
304+
console.log(sharedData.workspaceSettings.PreviewsEnabled);
305+
}
306+
307+
// Modify and save
308+
sharedData.workspaceSettings = {
309+
PreviewsEnabled: true,
310+
IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded: false,
311+
};
312+
sharedData.save();
313+
```
314+
315+
### Breakpoints API
316+
317+
Parse and build Xcode breakpoint files (`Breakpoints_v2.xcbkptlist`):
318+
319+
```ts
320+
import * as breakpoints from "@bacons/xcode/breakpoints";
321+
import fs from "fs";
322+
323+
// Parse breakpoint file
324+
const xml = fs.readFileSync(
325+
"/path/to/xcshareddata/xcdebugger/Breakpoints_v2.xcbkptlist",
326+
"utf-8",
327+
);
328+
const list = breakpoints.parse(xml);
329+
330+
// Access breakpoints
331+
for (const bp of list.breakpoints ?? []) {
332+
console.log(bp.breakpointExtensionID); // "Xcode.Breakpoint.FileBreakpoint"
333+
console.log(bp.breakpointContent?.filePath);
334+
console.log(bp.breakpointContent?.startingLineNumber);
335+
}
336+
337+
// Add a new breakpoint
338+
list.breakpoints?.push({
339+
breakpointExtensionID: "Xcode.Breakpoint.FileBreakpoint",
340+
breakpointContent: {
341+
uuid: "new-uuid",
342+
shouldBeEnabled: true,
343+
filePath: "MyApp/ViewController.swift",
344+
startingLineNumber: "42",
345+
endingLineNumber: "42",
346+
actions: [
347+
{
348+
actionExtensionID: "Xcode.BreakpointAction.DebuggerCommand",
349+
actionContent: { consoleCommand: "po self" },
350+
},
351+
],
352+
},
353+
});
354+
355+
// Serialize back to XML
356+
const outputXml = breakpoints.build(list);
357+
```
358+
359+
### Workspace Settings API
360+
361+
Parse and build workspace settings files (`WorkspaceSettings.xcsettings`):
362+
363+
```ts
364+
import * as settings from "@bacons/xcode/settings";
365+
import fs from "fs";
366+
367+
// Parse settings file
368+
const plist = fs.readFileSync(
369+
"/path/to/xcshareddata/WorkspaceSettings.xcsettings",
370+
"utf-8",
371+
);
372+
const config = settings.parse(plist);
373+
374+
console.log(config.BuildSystemType); // "Original" or "New"
375+
console.log(config.PreviewsEnabled); // true/false
376+
377+
// Modify and save
378+
config.PreviewsEnabled = true;
379+
config.IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded = false;
380+
381+
const outputPlist = settings.build(config);
382+
fs.writeFileSync("/path/to/WorkspaceSettings.xcsettings", outputPlist);
383+
```
384+
280385
## Solution
281386

282387
- Uses a hand-optimized single-pass parser that is 11x faster than the legacy `xcode` package (which uses PEG.js).
@@ -304,15 +409,14 @@ We support the following types: `Object`, `Array`, `Data`, `String`. Notably, we
304409
- [x] xcscheme support.
305410
- [x] Benchmarks (`bun run bench`).
306411
- [x] xcworkspace support.
412+
- [x] **XCSharedData**: Shared project data directory (schemes, breakpoints, workspace settings).
413+
- [x] **XCSchemeManagement**: Scheme ordering, visibility, and management plist.
414+
- [x] **WorkspaceSettings**: (`xcshareddata/WorkspaceSettings.xcsettings`) Derived data location, build system version, auto-create schemes setting.
415+
- [x] **XCBreakpointList**: (`xcshareddata/xcdebugger/Breakpoints_v2.xcbkptlist`) Shared debugger breakpoints (file, symbolic, exception breakpoints).
307416
- [ ] Create robust xcode projects from scratch.
308417
- [ ] Skills.
309418
- [ ] Import from other tools.
310419
- [ ] **XCConfig** Parsing: `.xcconfig` file parsing with `#include` support and build settings flattening.
311-
- [ ] **XCSharedData**: Shared project data directory (schemes, breakpoints, workspace settings).
312-
- [ ] **XCSchemeManagement**: Scheme ordering, visibility, and management plist. Controls which schemes appear and in what order in Xcode.
313-
- [ ] **XCUserData**: User-specific data (breakpoints, UI state). Useful for tooling that manages user preferences.
314-
- [ ] **WorkspaceSettings**: (`xcshareddata/WorkspaceSettings.xcsettings`) Derived data location, build system version, auto-create schemes setting.
315-
- [ ] **XCBreakpointList**: (`xcshareddata/xcdebugger/Breakpoints_v2.xcbkptlist`) Shared debugger breakpoints (file, symbolic, exception breakpoints)
316420
- [ ] **XCUserData**: (`xcuserdata/<user>.xcuserdatad/`) Per-user schemes, breakpoints, UI state.
317421
- [ ] **IDEWorkspaceChecks**: (`xcshareddata/IDEWorkspaceChecks.plist`) "Trust this project" flag that suppresses Xcode warning.
318422

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
"./workspace": {
3333
"types": "./build/workspace/index.d.ts",
3434
"default": "./build/workspace/index.js"
35+
},
36+
"./breakpoints": {
37+
"types": "./build/breakpoints/index.d.ts",
38+
"default": "./build/breakpoints/index.js"
39+
},
40+
"./settings": {
41+
"types": "./build/settings/index.d.ts",
42+
"default": "./build/settings/index.js"
3543
}
3644
},
3745
"files": [

0 commit comments

Comments
 (0)