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

plist-generator

v0.1.0

Published

This is a Node module for reading, modifying, and writing property list files. It was build with the specific purpose of adding libraries and frameworks to the .pbxproj file in an Xcode project. It therefore can parse and write property lists that are w

Downloads

5

Readme

Plist Generator

This is a Node module for reading, modifying, and writing property list files. It was build with the specific purpose of adding libraries and frameworks to the .pbxproj file in an Xcode project. It therefore can parse and write property lists that are written in Xcode's Open Step format.

Installation

npm install --save

API

The export from this module is a generator function that makes a plist javascript object from a source file.

var PlistObject = require('plist-generator');
var plistObject = new PlistObject(fs.readFileSync(<location of .pbxproj file>, 'utf8'));

Plist Object methods

These are several methods that are designed for adding files or shell scripts to a plist object. These should be sufficient for adding a group with header or archive files to your project or adding an embedded framework.

  • addFileReferenceToParent(parentName, fileName):
    • Adds a file reference to a file sitting at fileName with an appropriate "lastKnownFileType".
    • Adds the file reference to the list of children or files of an entry with the a name or path parameter that matches parentName.
    • If the "lastKnownFileType" is archive.ar, then this file is added to the LIBRARY_SEARCH_PATHS and the PBXFrameworksBuildPhase.
  • addGroupToParent(parentName, groupName, isPath):
    • Creates a new group with name groupName.
    • Adds it to the list of children of an entry with the a name or path parameter that matches parentName.
  • addShellScript(scriptContents):
    • Adds a new PBXShellScriptBuildPhase to the build phases list whose contents are scriptContents.
  • addFrameworkFile(fileName, directoryName, embed):
    • Adds a file reference to fileName as a child of the CustomTemplate.
    • Adds directoryName to the FRAMEWORK_SEARCH_PATHS for "Debug" and "Release".
    • If embed is truthy, add this file reference to the "Embed Frameworks" build phase.

Lower level methods

These methods are not designed to be used directly, but are used by the methods above. They are exposed for you to use directly if you want to use any of them.

  • allUuids(): Returns the list of every uuid that is used in this plist
  • generateUuid(): Returns a valid uuid that isn't already in use
  • findObject(searchParams): returns the first object to match the searchParams. If searchParams is a string, then this will only find an object whose "name" or "path" value matches the string exactly. If searchParams is an object, then this will only find object that matches each of the key-value pairs in the searchParams object. If no matches are found, this returns undefined.
  • addDict(uuid, isa, otherProps): Adds a new dict with the given uuid. Every dict has the given isa property and whatever props are in the otherProps object.
  • addChildToParent(searchParams, isa, childObject, isLibraryFile): This method is called by both addFileReferenceToParent and addGroupToParent.
    • Uses findObject(searchParams) to find the appropriate parent and adds a newUuid to this parent's children.
    • Calls addDict(newUuid, isa, childObject) to make the child.
    • If isLibraryFile is truthy, then calls addLibraryFile(newUuid, searchParams).
  • addBuildPhase(isa, options): This method is used by addShellScript and addFrameworkFile. It simply calls adds a newUuid to the list of "buildPhases" in the PBXNativeTarget and then calls addDict(newUuid, isa, options).
  • addLibraryFile(newUuid, directoryName):
    • Adds directoryName to the LIBRARY_SEARCH_PATHS in both "Debug" and "Release".
    • Adds a fileRef to newUuid as a child of the PBXFrameworksBuildPhase.

Example

// Create PlistObject to track changes to the project.pbxproj file
var fs = require('fs');
var PlistObject = require('plist-generator');
var plistObject = new PlistObject(fs.readFileSync(<file path to .pbxproj file>, 'utf8'));

// Add TwilioVoiceClient.framework, which is sitting in the root of the iOS
//  project, to Frameworks and Embed Frameworks
plistObject.addFrameworkFile('TwilioVoiceClient.framework', '', true);
// Add a run script to modify the binary TwilioVoiceClient when making builds
//  so that they only contain the appropriate binaries.
var runScriptContents = 'APP_PATH=\\"${TARGET_BUILD_DIR}/${WRAPPER_NAME}\\"\\n\\n' +
  '# This script loops through the frameworks embedded in the application and\\n' +
  '# removes unused architectures.\\nfind \\"$APP_PATH\\" -name \'*.framework\'' +
  ' -type d | while read -r FRAMEWORK\\ndo\\n' +
  'FRAMEWORK_EXECUTABLE_NAME=$(defaults read \\"$FRAMEWORK/Info.plist\\" ' +
  'CFBundleExecutable)\\nFRAMEWORK_EXECUTABLE_PATH=\\"$FRAMEWORK/' +
  '$FRAMEWORK_EXECUTABLE_NAME\\"\\necho \\"Executable is ' +
  '$FRAMEWORK_EXECUTABLE_PATH\\"\\n\\nEXTRACTED_ARCHS=()\\n\\nfor ARCH in ' +
  '$ARCHS\\ndo\\necho \\"Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME\\"\\n' +
  'lipo -extract \\"$ARCH\\" \\"$FRAMEWORK_EXECUTABLE_PATH\\" -o ' +
  '\\"$FRAMEWORK_EXECUTABLE_PATH-$ARCH\\"\\n' +
  'EXTRACTED_ARCHS+=(\\"$FRAMEWORK_EXECUTABLE_PATH-$ARCH\\")\\ndone\\n\\n' +
  'echo \\"Merging extracted architectures: ${ARCHS}\\"\\nlipo -o ' +
  '\\"$FRAMEWORK_EXECUTABLE_PATH-merged\\" -create \\"${EXTRACTED_ARCHS[@]}\\"\\n' +
  'rm \\"${EXTRACTED_ARCHS[@]}\\"\\n\\necho \\"Replacing original executable with ' +
  'thinned version\\"\\nrm \\"$FRAMEWORK_EXECUTABLE_PATH\\"\\n' +
  'mv \\"$FRAMEWORK_EXECUTABLE_PATH-merged\\" \\"$FRAMEWORK_EXECUTABLE_PATH\\"\\n\\n' +
  'done';
plistObject.addShellScript(runScriptContents);

fs.writeFileSync(<file path to .pbxproj file>, plistObject.build());