Xcode Extension

Supercharge Your Xcode with JavaScript

JSPower is an Xcode extension that provides a development interface for the JavaScript language. Anyone can create Xcode extension utilities using JavaScript.

ASCII Text Demo
JSPower ASCII Text Demo

Builtin Utilities

Powerful tools to enhance your Xcode development workflow

ASCII Text

Convert selected text into ASCII Text format with a single click.

Convert selected text into ASCII Text.

Sort Lines

Sort selected lines alphabetically or numerically.

Sort your code or text lines with ease.

Block Comment

Quickly add or remove block comments from your code.

/* Comment blocks of code */

Jump Up/Down Lines

Navigate through your code more efficiently.

Move lines up or down quickly.

How to enable in Xcode

After installing JSPower from the Mac App Store, follow these steps to enable it in Xcode:

  1. Open Xcode and go to Xcode > Settings...
  2. Select the Extensions tab
  3. Find JSPower in the list and check the box next to it
  4. Restart Xcode for the changes to take effect
  5. You can now access JSPower from the Editor menu in Xcode

!If you don't see JSPower in the Extensions list, try restarting your Mac and opening Xcode again.

How To Create Your Own Package

JSPower's builtin utilities are implemented in JavaScript language, for examples,ASCII Text andSort lines. Source code of them is Here.

This is called a package.

Package structure

manifest.json contains all required information for the package:

  1. name/version/author/website/description
  2. menu items

Tutorial

  1. Create GitHub Pages like this one: jspowerx.github.io, and clone packages/helloworld directory.
  2. Create manifest.json inpackages/helloworld directory, and create directory for each menu item withmenu id.
{
    "name":"Hello world",
    "version":"1.0",
    "author":"Your Name",
    "website":"https://yourwebsite.com",
    "description":"Your awesome package description",
    "menu":[
        {
            "id":"hello",
            "title":"Say Hello",
            "shortcut":"cmd+shift+h"
        }
    ]
}

More Detail

  • Each menu's JavaScript is run under separated context.
  • entry.js describes all the JavaScript files and the run order the menu includes.
  • Menu id can include a dot for supply 2 or more menu items in one menu directory. e.g. See the Jump Menu Id

Open Source Packages

The builtin and DLC Pack 1 is opensource under Here

API Document

There are two global variable now, invocation and system.

invocation

getter and setter
  • invocation.contentUTI - The Unique Type Identifier (UTI) of the content in the buffer.
  • invocation.tabWidth - The number of space characters represented by a tab character in the buffer.
  • invocation.indentationWidth - The number of space characters used for indentation of the text in the buffer.
  • invocation.usesTabsForIndentation - A Boolean value that indicates whether tabs are used for indentation.
  • invocation.selectionExist - Whether there is selection of text.
  • invocation.selections - Array of arrays of integers representing selection ranges.
  • invocation.firstSelection - Array of integers representing the first selection range.
  • invocation.selectionStrings - Array of strings representing selected text.
  • invocation.selectionLines - Array of strings representing selected lines.
  • invocation.completeBuffer - All the content of current file.
  • invocation.lines - Array of strings representing all lines in the file.
  • invocation.lineCount - Line count of current file.
methods
  • invocation.insertLinesAtIndex(ArrayOfString,Integer) - Insert lines at specified line index.
  • invocation.appendLines(ArrayOfString) - Append lines to the end of current file.
  • invocation.removeLinesFromTo(Integer,Integer) - Remove lines from line index to line index.
  • invocation.assignLineAtIndex(String,Integer) - Assign string to line at index.

system

methods
  • system.log(String) - Log string using NSLog.
  • system.openURL(String) - Open URL.

Marketplace

Discover and install community-created packages to extend JSPower's functionality.

NameAuthorURLDescription
JSPower ExtendeverettjfView PackageBlock comment, Jump Up/Down lines

Share Your Package

Feel free to share your awesome packages with us! Send your package information to: