Expand description
Minimal ObjC runtime FFI for Apple framework crates.
Provides the raw ObjC runtime symbols (objc_msgSend, objc_getClass,
sel_registerName) plus ergonomic helper macros so framework crates can
call ObjC methods directly from Rust — no .m files, no cc build step.
§Example
ⓘ
use apple_objc_sys::*;
unsafe {
let cls = class!(b"NSProcessInfo");
let info: Id = msg_send![cls, processInfo];
let count: isize = msg_send![info, processorCount];
}§License
GPL-3.0 — Copyright © 2025 Eugene Hauptmann
Macros§
- class
- Look up an ObjC class by name (null-terminated byte string).
- msg_
send - Send an ObjC message. Returns
Idby default. - msg_
send_ t - Send an ObjC message that returns a typed non-Id value (bool, isize, f64, etc.).
- msg_
send_ void - Void-returning ObjC message send.
- sel
- Register / look up an ObjC selector (null-terminated byte string).
Constants§
Statics§
Functions§
- CFData
Create ⚠ - CFData
GetByte ⚠Ptr - CFData
GetLength ⚠ - CFDictionary
Create ⚠ - CFRelease⚠
- CFRetain⚠
- CFString
Create ⚠With Bytes - CFString
GetC ⚠String - CFString
GetC ⚠String Ptr - CFString
GetLength ⚠ - cfdict⚠
- Build a
CFDictionaryReffrom parallel key/value slices. - dlsym_
global ⚠ - Look up a global symbol by name via
dlsym(RTLD_DEFAULT, name). - global_
string_ ⚠const - Read a global
NSString*/CFStringRefconstant by symbol name. Many Apple framework constants (e.g.kSecClass) are pointers toCFStringRef— this dereferences the pointer. - nsstring⚠
- Create an autoreleased
NSStringfrom a Rust&str. - nsstring_
to_ ⚠buf - Write an
NSString*into a(buf, len)pair, returning bytes written or -1. - nsstring_
to_ ⚠string - Read an
NSString*(toll-free bridgedCFStringRef) into a RustString. - objc_
getClass ⚠ - objc_
msgSend ⚠ - objc_
msgSend_ ⚠stret objc_msgSendvariant for stret on x86_64 (structs > 16 bytes).- sel_
register ⚠Name
Type Aliases§
- CFAllocator
Ref - CFData
Ref - CFDictionary
Ref - CFIndex
- CFString
Ref - CFType
Ref - Class
- Opaque ObjC class pointer.
- Id
- Opaque ObjC object pointer.
- Sel
- Opaque ObjC selector pointer.