objc-js
v1.0.4
Published
Objective-C bridge for Node.js
Downloads
2,148
Readme
objc-js
objc-js is an Objective-C bridge for Node.js. This is a fork of nobjc by Noah Gregory.
Installation
Prerequisites
- Node.js / Bun
- Xcode Command Line Tools (Run
xcode-select --installto install) pkg-configfrom Homebrew (Runbrew install pkgconfto install)
[!NOTE] Why are these prerequisites required?
These are required to rebuild the native code for your system.
Install using npm
npm install objc-jsInstall using bun
bun add objc-js
# and `bun pm trust -a` to run the rebuild if neededDocumentation
The documentation is organized into several guides:
- Basic Usage - Getting started with loading frameworks and calling methods
- Subclassing Objective-C Classes - Creating and subclassing Objective-C classes from JavaScript
- Protocol Implementation - Creating delegate objects that implement protocols
- API Reference - Complete API documentation for all classes and functions
Quick Start
import { NobjcLibrary } from "objc-js";
// Load a framework
const foundation = new NobjcLibrary("/System/Library/Frameworks/Foundation.framework/Foundation");
// Get a class and call methods
const NSString = foundation["NSString"];
const str = NSString.stringWithUTF8String$("Hello, World!");
console.log(str.toString());For more examples and detailed guides, see the documentation.
