Skip to content
oprayingPublic

About

Apple platform bindings for MoonBit, generated from the system SDK, with a hand-written runtime.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

82 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opraying/objc2

Apple platforms for MoonBit: macOS, iOS, tvOS, watchOS, visionOS, and Mac Catalyst. Generated packages cover the system frameworks. A hand-written runtime supplies objects, blocks, and a scoped lock around calls into the Objective-C runtime.

Scripts

./scripts/objc2-build.sh is the entry point: generate, check, test, build, run, bundle, and pack. ./scripts/ci.sh is the full gate. ./scripts/new-app.sh scaffolds an example. Commands and invariants are in AGENTS.md.

Design

Frameworks are generated from the Apple SDK. The layering follows the Rust objc2 project: a runtime, a generated raw layer, and a typed overlay where strings and errors should be MoonBit values. The deployment floor is enforced by scripts/min-os.env. An API newer than that floor fails with CocoaError instead of crashing.

Example

examples/hello is a headless Foundation smoke test. It builds a string, a data blob, and an array:

fn main {
  let hello = @Foundation.NSString::of("hello, objc2")
  println("length=\{hello.length()} text=\{hello.to_string()}")
  let data = @Foundation.NSData::from_bytes(b"objc2")
  println("bytes=\{data.length()}")
  let arr = @Foundation.NSArray::of([hello])
  println("count=\{arr.count()}")
}

examples/showcase opens a window with AppKit controls and a Metal view. examples/menubar is a menu-bar app. examples/counter and examples/habits are small interactive apps.

Layers

Objc2Runtime is the runtime: objects, blocks, dispatch, and errors. Generated framework packages are the raw selectors and C functions. Typed helpers, such as NSString::of, accept and return MoonBit strings.

Hand-written sources

Most top-level framework directories are generated bindings linked from the generated/ submodule (opraying/mbt-generated, branch objc2). Focus edits on the hand-written core and generator:

Real-Time Threads

MoonBit's native reference-counting runtime uses a scoped GIL (Objc2Runtime) and must never be entered from a Mach real-time thread (THREAD_TIME_CONSTRAINT_POLICY, such as a CoreAudio / AudioUnit render callback). Call @Objc2Runtime.is_realtime_thread() to detect real-time threads, keep audio/DSP render callbacks in lock-free C/ObjC, and set OBJC2_ABORT_ON_RT_GIL=1 during testing to fail loudly if any callback attempts to acquire the MoonBit GIL on a real-time thread.

License

Apache-2.0. Copyright the opraying contributors.

About

Apple platform bindings for MoonBit, generated from the system SDK, with a hand-written runtime.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages