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 🙏

© 2024 – Pkg Stats / Ryan Hefner

xcparse

v0.0.3

Published

pbxproj parser

Downloads

16,355

Readme

xcparse

This project is a ~~work in progress / proof of concept~~ seemingly spec compliant pbxproj parser. The API is subject to breaking changes.

yarn add xcparse

Website https://xcode-seven.vercel.app/

Here is a diagram of the grammar used for parsing:

Why

The most popular solution for parsing pbxproj files is a very old package by Cordova called xcode.

But xcode has some major issues:

  • Inaccurate parsing: strings can be quoted incorrectly very often, lists often don't work.
  • Outdated: values for App Clips, iMessage Sticker packs, etc are missing.
  • Untyped: TypeScript is a crutch I proudly support.
  • Slow: PEG.js is not very fast (benchmark).
  • Feature Incomplete: Missing the Data type (<xx xx xx>).

Solution

  • Unlike the xcode package which uses PEG.js, this implementation uses Chevrotain.
  • This project support the Data type <xx xx xx>.
  • Unopinionated: this could change in the future :] but if it does we'll use modern graph API patterns that are typed.
  • This implementation also appears to be more stable since we follow the best guess pbxproj spec.
  • String parsing is the trickiest part. This package uses a port of the actual CFOldStylePlist parser which is an approach first used at scale by the CocoaPods team (originally credited to Samantha Marshall).

How

The parsing is very simple (simplicity is the key).

pbxproj is an "old-style plist" (or ASCII Plist), this means it should be possible to represent it as any other static configuration file type like JSON or XML.

We support the following types: Object, Array, Data, String. Notably, we avoid dealing with Integer, Double, Boolean since they appear to not exist in the format.

TODO

  • [x] Reading.
  • [x] Writing.
  • [x] Escaping scripts and header search paths.
  • [x] Use a fork of chevrotain -- it's way too large for what it offers.
  • [ ] Generating UUIDs.
  • [ ] The API would probably be implemented using unist
  • [ ] Docs

Docs

Docs are in the works. For now, you can refer to the types and the estimated pbxproj spec.

The API will change in the future, for now we have two methods:

import { 
    /** Given a stringified `pbxproj`, return a JSON representation of the object. */
    parse, 
    /** Given a JSON representation of a `pbxproj`, return a `.pbxproj` string that can be parsed by Xcode. */
    build 
} from 'xctrace'

import fs from 'fs';
import path from 'path';

const pbxproj = parse(fs.readFileSync('/path/to/project.pbxproj'));

const pbxprojString = build(pbxproj);