Skip to content

Commit cc36a99

Browse files
EvanBaconclaude
andauthored
Add XCUserData support for per-user Xcode data (#47)
Adds high-level API for accessing and manipulating user data directories (xcuserdata/{user}.xcuserdatad/) which contain per-user schemes, breakpoints, and scheme management. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c3ddfb6 commit cc36a99

5 files changed

Lines changed: 844 additions & 1 deletion

File tree

README.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,78 @@ list.breakpoints?.push({
458458
const outputXml = breakpoints.build(list);
459459
```
460460

461+
## XCUserData Support
462+
463+
Access and manipulate user data directories (`xcuserdata`) which contain per-user schemes, breakpoints, and scheme management. Unlike shared data, user data is per-developer and typically not checked into version control.
464+
465+
### High-level API
466+
467+
```ts
468+
import { XcodeProject, XCUserData } from "@bacons/xcode";
469+
470+
// Get user data from a project
471+
const project = XcodeProject.open("/path/to/project.pbxproj");
472+
473+
// Get all users
474+
const allUserData = project.getAllUserData();
475+
for (const userData of allUserData) {
476+
console.log(`User: ${userData.userName}`);
477+
console.log(`Schemes: ${userData.getSchemes().length}`);
478+
}
479+
480+
// Get data for a specific user
481+
const myUserData = project.getUserData("johnsmith");
482+
483+
// Access user schemes
484+
const schemes = myUserData.getSchemes();
485+
const debugScheme = myUserData.getScheme("MyApp-Debug");
486+
487+
// Access user breakpoints
488+
if (myUserData.breakpoints) {
489+
console.log(myUserData.breakpoints.breakpoints?.length);
490+
}
491+
492+
// Access scheme management (order, visibility)
493+
if (myUserData.schemeManagement) {
494+
console.log(myUserData.schemeManagement.SchemeUserState);
495+
}
496+
497+
// Modify and save
498+
myUserData.breakpoints = {
499+
uuid: "new-uuid",
500+
type: "1",
501+
version: "2.0",
502+
breakpoints: [],
503+
};
504+
myUserData.save();
505+
```
506+
507+
### Standalone Usage
508+
509+
```ts
510+
import { XCUserData } from "@bacons/xcode";
511+
512+
// Open existing user data
513+
const userData = XCUserData.open(
514+
"/path/to/Project.xcodeproj/xcuserdata/username.xcuserdatad"
515+
);
516+
console.log(userData.userName); // "username"
517+
518+
// Create new user data
519+
const newUserData = XCUserData.create("newuser");
520+
newUserData.schemeManagement = {
521+
SchemeUserState: {
522+
"App.xcscheme": { orderHint: 0 },
523+
},
524+
};
525+
newUserData.save("/path/to/Project.xcodeproj/xcuserdata/newuser.xcuserdatad");
526+
527+
// Discover all users in a project
528+
const users = XCUserData.discoverUsers(
529+
"/path/to/Project.xcodeproj/xcuserdata"
530+
);
531+
```
532+
461533
### Workspace Settings API
462534

463535
Parse and build workspace settings files (`WorkspaceSettings.xcsettings`):
@@ -613,7 +685,7 @@ We support the following types: `Object`, `Array`, `Data`, `String`. Notably, we
613685
- [ ] Create robust xcode projects from scratch.
614686
- [ ] Skills.
615687
- [ ] Import from other tools.
616-
- [ ] **XCUserData**: (`xcuserdata/<user>.xcuserdatad/`) Per-user schemes, breakpoints, UI state.
688+
- [x] **XCUserData**: (`xcuserdata/<user>.xcuserdatad/`) Per-user schemes, breakpoints, UI state.
617689
- [x] **IDEWorkspaceChecks**: (`xcshareddata/IDEWorkspaceChecks.plist`) Workspace check state storage (e.g., 32-bit deprecation warning).
618690
- [x] **Swift Package Manager**: Add remote and local SPM dependencies with automatic wiring.
619691

0 commit comments

Comments
 (0)