Skip to content

Add XCScheme support for parsing and building Xcode scheme files - #34

Merged
EvanBacon merged 1 commit into
mainfrom
@evanbacon/xcscheme
Feb 27, 2026
Merged

EvanBacon merged 1 commit into
mainfrom
@evanbacon/xcscheme

Conversation

@EvanBacon

Copy link
Copy Markdown
Owner

Summary

  • Adds comprehensive XCScheme support for parsing and building .xcscheme files
  • Provides low-level API (@bacons/xcode/scheme) similar to the existing JSON API
  • Provides high-level API with XCScheme class integrated into XcodeProject
  • Includes support for xcschememanagement.plist files
  • Adds 41 new tests (266 total tests now passing)

Features

Low-level API

import * as scheme from "@bacons/xcode/scheme";

// Parse and build xcscheme files
const xcscheme = scheme.parse(xml);
const xml = scheme.build(xcscheme);

// Parse and build xcschememanagement.plist
const management = scheme.parseManagement(plist);
const plist = scheme.buildManagement(management);

High-level API

import { XcodeProject, XCScheme } from "@bacons/xcode";

const project = XcodeProject.open("/path/to/project.pbxproj");

// Get existing schemes
const schemes = project.getSchemes();
const appScheme = project.getScheme("App");

// Create and save new schemes
const newScheme = XCScheme.create("MyScheme");
newScheme.addBuildTarget(buildableRef);
newScheme.setLaunchEnvironmentVariable("DEBUG", "1");
project.saveScheme(newScheme);

// Create scheme for target
const targetScheme = project.createSchemeForTarget(mainTarget);
project.saveScheme(targetScheme);

New Files

  • src/scheme/types.ts - TypeScript interfaces for all scheme elements
  • src/scheme/parser.ts - XML parser using @xmldom/xmldom
  • src/scheme/writer.ts - XML serializer
  • src/scheme/management.ts - xcschememanagement.plist support
  • src/scheme/index.ts - Module exports
  • src/api/XCScheme.ts - High-level scheme class
  • scheme.js, scheme.d.ts - Entry points

Test plan

  • Run yarn build - compiles successfully
  • Run yarn test - all 266 tests pass
  • Parse various xcscheme fixtures from XcodeProj
  • Verify round-trip (parse → build → parse produces identical results)
  • Test XcodeProject integration methods

🤖 Generated with Claude Code

This adds comprehensive support for .xcscheme files with:

- Low-level parsing/building API (src/scheme/)
  - Parse xcscheme XML to typed TypeScript objects
  - Build typed objects back to XML
  - Support for xcschememanagement.plist files

- High-level API (src/api/XCScheme.ts)
  - XCScheme class with convenient methods
  - XcodeProject integration (getSchemes, saveScheme, etc.)

- Entry points (scheme.js, scheme.d.ts)
- Comprehensive tests with fixtures from XcodeProj

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@EvanBacon
EvanBacon merged commit 09f7a89 into main Feb 27, 2026
1 check passed
@EvanBacon
EvanBacon deleted the @evanbacon/xcscheme branch February 27, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant