npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pragma.tools/pbxproj

v1.0.0

Published

Parser and serializer for .pbxproj files with customizing comment strategies

Downloads

5

Readme

pragma-pbxproj

Parser and builder for .pbxproj files with comment strategies

Installation

npm install @pragma.tools/pbxproj

Usage

Node.js API

import { parse, serialize, stringify } from '@pragma.tools/pbxproj';
import fs from 'fs';

// Read .pbxproj file
const pbxprojContent = fs.readFileSync('MyApp.xcodeproj/project.pbxproj', 'utf8');

// Parse to AST
const ast = parse(pbxprojContent);

// Serialize back to .pbxproj format
const serialized = serialize(ast, { 
  commentStrategy: 'generate' // 'preserve', 'strip', 'generate', or custom function
});

// Or use stringify (alias for serialize)
const stringified = stringify(ast, { commentStrategy: 'generate' });

console.log(serialized);

Examples

Input .pbxproj file

// !$*UTF8*$!
{
	archiveVersion = 1;
	classes = {
	};
	objectVersion = 56;
	objects = {

/* Begin PBXBuildFile section */
		1A2B3C4D5E6F7890ABCDEF01 /* AppDelegate.swift in Sources */ = {
			isa = PBXBuildFile; 
			fileRef = 1A2B3C4D5E6F7890ABCDEF02 /* AppDelegate.swift */; 
		};
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
		1A2B3C4D5E6F7890ABCDEF02 /* AppDelegate.swift */ = {
			isa = PBXFileReference; 
			lastKnownFileType = sourcecode.swift; 
			path = AppDelegate.swift; 
			sourceTree = "<group>"; 
		};
/* End PBXFileReference section */

	};
	rootObject = 1A2B3C4D5E6F7890ABCDEF06 /* Project object */;
}

Parsed AST (JSON)

{
  "archiveVersion": 1,
  "objectVersion": 56,
  "objects": {
    "1A2B3C4D5E6F7890ABCDEF01": {
      "isa": "PBXBuildFile",
      "fileRef": "1A2B3C4D5E6F7890ABCDEF02"
    },
    "1A2B3C4D5E6F7890ABCDEF02": {
      "isa": "PBXFileReference",
      "lastKnownFileType": "sourcecode.swift",
      "path": "AppDelegate.swift",
      "sourceTree": "<group>"
    }
  },
  "rootObject": "1A2B3C4D5E6F7890ABCDEF06"
}

Serialized .pbxproj with generated comments

archiveVersion = 1;
objectVersion = 56;
objects = {
  1A2B3C4D5E6F7890ABCDEF01 /* PBXBuildFile */ = {
    "isa" = "PBXBuildFile";
    "fileRef" = "1A2B3C4D5E6F7890ABCDEF02";
  };
  1A2B3C4D5E6F7890ABCDEF02 /* AppDelegate.swift */ = {
    "isa" = "PBXFileReference";
    "lastKnownFileType" = "sourcecode.swift";
    "path" = "AppDelegate.swift";
    "sourceTree" = "<group>";
  };
};
rootObject = 1A2B3C4D5E6F7890ABCDEF06;

CLI

# Parse and rebuild with generated comments
pbxproj path/to/project.pbxproj

# Or using npx
npx @pragma.tools/pbxproj path/to/project.pbxproj

Comment Strategies

  • preserve - Keep original comments (default)
  • strip - Remove all comments
  • generate - Generate comments based on object properties
  • Custom function - Provide your own comment generator

API Reference

parse(pbxprojText, options = {})

Parses .pbxproj file content into AST.

serialize(ast, options = {})

Serializes AST back to .pbxproj format.

stringify(ast, options = {})

Alias for serialize function.

Legacy Support

  • build(ast, options = {}) - Legacy alias for serialize, maintained for backward compatibility

Testing

# Run tests in watch mode
npm test

# Run tests once
npm run test:run

# Run tests in watch mode
npm run test:watch

The project includes comprehensive tests covering:

  • Unit tests - Individual function testing (parse, build, generateComment)
  • Integration tests - Full parse-build cycle testing
  • CLI tests - Command-line interface testing
  • Edge cases - Error handling and boundary conditions

Test coverage includes:

  • ✅ All main module exports
  • ✅ Different comment strategies
  • ✅ Error handling scenarios
  • ✅ CLI argument validation
  • ✅ File I/O operations

Author

Denis Kreshikhin [email protected]

License

MIT