Objective-C Runtime bindings and wrapper for Rust, enabling safe interoperability and class declaration.
rust-objc is a Rust library that provides bindings and a wrapper for the Objective-C runtime, enabling Rust code to interact with Objective-C objects, call methods, manage memory, and even declare new Objective-C classes. It solves the problem of integrating Rust with Objective-C-based systems, such as macOS/iOS frameworks or GNUstep applications, by offering safe and ergonomic abstractions.
Rust developers working on macOS, iOS, or GNUstep projects who need to interface with Objective-C libraries, or developers building cross-platform tools that require Objective-C compatibility.
Developers choose rust-objc for its safety-focused design, which includes ARC-like memory management and optional exception handling, along with features like message type verification to prevent runtime errors. It provides a more Rust-idiomatic way to work with Objective-C compared to raw FFI.
Objective-C Runtime bindings and wrapper for Rust.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The `msg_send!` macro provides a Rust-like syntax for Objective-C method calls, reducing boilerplate and error-prone raw FFI code, as shown in the README examples for messaging objects like NSObject.
Offers `StrongPtr` and `WeakPtr` for automatic reference counting, ensuring safe memory handling of Objective-C objects without manual retain/release, with examples in the reference counting section.
Allows declaring new Objective-C classes from Rust with `ClassDecl`, enabling integration and extension of Objective-C ecosystems, demonstrated by creating a custom MyNumber class with ivars and methods.
Includes features like exception handling and message type verification to prevent unsafe unwinding and ensure type correctness, though they require explicit enabling via cargo features.
Critical safety features like exception handling and message verification are optional, meaning developers must manually enable them to avoid undefined behavior, adding configuration complexity.
Using rust-objc on Linux or *BSD requires installing and configuring the GNUstep Objective-C runtime, which involves additional dependencies and setup steps outside standard Rust tooling.
Documentation is primarily API references with limited tutorials or real-world examples, making it challenging for developers new to Rust-Objective-C interoperability to get started effectively.