@@ -355,6 +355,111 @@ PRODUCT_BUNDLE_IDENTIFIER = $(BUNDLE_ID_PREFIX).$(PRODUCT_NAME:lower)
355355OTHER_LDFLAGS = $(inherited) -framework UIKit
356356```
357357
358+ ## XCSharedData Support
359+
360+ Access and manipulate shared data directories (` xcshareddata ` ) which contain schemes, breakpoints, and workspace settings that are intended for version control.
361+
362+ ### High-level API
363+
364+ ``` ts
365+ import { XcodeProject , XCSharedData } from " @bacons/xcode" ;
366+
367+ // Get shared data from a project
368+ const project = XcodeProject .open (" /path/to/project.pbxproj" );
369+ const sharedData = project .getSharedData ();
370+
371+ // Access schemes
372+ const schemes = sharedData .getSchemes ();
373+ const appScheme = sharedData .getScheme (" App" );
374+
375+ // Access breakpoints
376+ if (sharedData .breakpoints ) {
377+ console .log (sharedData .breakpoints .breakpoints ?.length );
378+ }
379+
380+ // Access workspace settings
381+ if (sharedData .workspaceSettings ) {
382+ console .log (sharedData .workspaceSettings .PreviewsEnabled );
383+ }
384+
385+ // Modify and save
386+ sharedData .workspaceSettings = {
387+ PreviewsEnabled: true ,
388+ IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded: false ,
389+ };
390+ sharedData .save ();
391+ ```
392+
393+ ### Breakpoints API
394+
395+ Parse and build Xcode breakpoint files (` Breakpoints_v2.xcbkptlist ` ):
396+
397+ ``` ts
398+ import * as breakpoints from " @bacons/xcode/breakpoints" ;
399+ import fs from " fs" ;
400+
401+ // Parse breakpoint file
402+ const xml = fs .readFileSync (
403+ " /path/to/xcshareddata/xcdebugger/Breakpoints_v2.xcbkptlist" ,
404+ " utf-8" ,
405+ );
406+ const list = breakpoints .parse (xml );
407+
408+ // Access breakpoints
409+ for (const bp of list .breakpoints ?? []) {
410+ console .log (bp .breakpointExtensionID ); // "Xcode.Breakpoint.FileBreakpoint"
411+ console .log (bp .breakpointContent ?.filePath );
412+ console .log (bp .breakpointContent ?.startingLineNumber );
413+ }
414+
415+ // Add a new breakpoint
416+ list .breakpoints ?.push ({
417+ breakpointExtensionID: " Xcode.Breakpoint.FileBreakpoint" ,
418+ breakpointContent: {
419+ uuid: " new-uuid" ,
420+ shouldBeEnabled: true ,
421+ filePath: " MyApp/ViewController.swift" ,
422+ startingLineNumber: " 42" ,
423+ endingLineNumber: " 42" ,
424+ actions: [
425+ {
426+ actionExtensionID: " Xcode.BreakpointAction.DebuggerCommand" ,
427+ actionContent: { consoleCommand: " po self" },
428+ },
429+ ],
430+ },
431+ });
432+
433+ // Serialize back to XML
434+ const outputXml = breakpoints .build (list );
435+ ```
436+
437+ ### Workspace Settings API
438+
439+ Parse and build workspace settings files (` WorkspaceSettings.xcsettings ` ):
440+
441+ ``` ts
442+ import * as settings from " @bacons/xcode/settings" ;
443+ import fs from " fs" ;
444+
445+ // Parse settings file
446+ const plist = fs .readFileSync (
447+ " /path/to/xcshareddata/WorkspaceSettings.xcsettings" ,
448+ " utf-8" ,
449+ );
450+ const config = settings .parse (plist );
451+
452+ console .log (config .BuildSystemType ); // "Original" or "New"
453+ console .log (config .PreviewsEnabled ); // true/false
454+
455+ // Modify and save
456+ config .PreviewsEnabled = true ;
457+ config .IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded = false ;
458+
459+ const outputPlist = settings .build (config );
460+ fs .writeFileSync (" /path/to/WorkspaceSettings.xcsettings" , outputPlist );
461+ ```
462+
358463## Solution
359464
360465- Uses a hand-optimized single-pass parser that is 11x faster than the legacy ` xcode ` package (which uses PEG.js).
@@ -382,15 +487,14 @@ We support the following types: `Object`, `Array`, `Data`, `String`. Notably, we
382487- [x] xcscheme support.
383488- [x] Benchmarks (` bun run bench ` ).
384489- [x] xcworkspace support.
490+ - [x] ** XCConfig** Parsing: ` .xcconfig ` file parsing with ` #include ` support and build settings flattening.
491+ - [x] ** XCSharedData** : Shared project data directory (schemes, breakpoints, workspace settings).
492+ - [x] ** XCSchemeManagement** : Scheme ordering, visibility, and management plist.
493+ - [x] ** WorkspaceSettings** : (` xcshareddata/WorkspaceSettings.xcsettings ` ) Derived data location, build system version, auto-create schemes setting.
494+ - [x] ** XCBreakpointList** : (` xcshareddata/xcdebugger/Breakpoints_v2.xcbkptlist ` ) Shared debugger breakpoints (file, symbolic, exception breakpoints).
385495- [ ] Create robust xcode projects from scratch.
386496- [ ] Skills.
387497- [ ] Import from other tools.
388- - [x] ** XCConfig** Parsing: ` .xcconfig ` file parsing with ` #include ` support and build settings flattening.
389- - [ ] ** XCSharedData** : Shared project data directory (schemes, breakpoints, workspace settings).
390- - [ ] ** XCSchemeManagement** : Scheme ordering, visibility, and management plist. Controls which schemes appear and in what order in Xcode.
391- - [ ] ** XCUserData** : User-specific data (breakpoints, UI state). Useful for tooling that manages user preferences.
392- - [ ] ** WorkspaceSettings** : (` xcshareddata/WorkspaceSettings.xcsettings ` ) Derived data location, build system version, auto-create schemes setting.
393- - [ ] ** XCBreakpointList** : (` xcshareddata/xcdebugger/Breakpoints_v2.xcbkptlist ` ) Shared debugger breakpoints (file, symbolic, exception breakpoints)
394498- [ ] ** XCUserData** : (` xcuserdata/<user>.xcuserdatad/ ` ) Per-user schemes, breakpoints, UI state.
395499- [ ] ** IDEWorkspaceChecks** : (` xcshareddata/IDEWorkspaceChecks.plist ` ) "Trust this project" flag that suppresses Xcode warning.
396500
0 commit comments