Important
These bindings are work in progress. They may not function correctly or have a nasty api. Expect major changes to the runtime and how that impacts the frameworks.
objective-zig
is a work-in-progress Objective-C runtime and auto generated collection of Objective-C frameworks in zig. You can find the bindings generator at objective-zig-gen. These bindings are not ready. See the notice at the bottom of the README.
The runtime is based off of other Zig Objective-C runtimes (objz, zig-objc, and mach_objc).
- CoreFoundation
- Foundation
- AppKit
- Metal
- ApplicationServices
- CloudKit
- CoreData
- CoreGraphics
- CoreImage
- CoreServices
- CoreText
- CoreVideo
- DiskArbitration
- ImageIO
- IOKit
- IOSurface
- OpenGL
- QuartzCore
- Security
- CoreLocation
- AddressBook
- Contacts
- CoreSpotlight
- EventKit
- Intents
- IntentsUI
- MapKit
- UniformTypeIdentifiers
- UserNotifications
- Symbols
- AVFoundation
- CoreMedia
- CoreAudioTypes
- CoreAudio
- MediaToolbox
- AudioToolbox
- AVFAudio
- CoreMIDI
const objz = @import("objective-zig");
const app_kit = objz.app_kit;
const foundation = objz.foundation;
pub fn main() void {
const autorelease_pool = objz.autoreleasePoolPush();
defer objz.autoreleasePoolPop(autorelease_pool);
// Create the shared application.
const app = app_kit.Application.sharedApplication().?;
// Spawn a 1280 x 720 window in the bottom left corner.
const rect = foundation.Rect{
.origin = .{
.x = 0,
.y = 0,
},
.size = .{
.width = 1280,
.height = 720,
},
};
// Create a window that has a title bar with a close button and is resizable.
const style_mask = app_kit.WindowStyleMask_Titled | app_kit.WindowStyleMask_Closable | app_kit.WindowStyleMask_Resizable;
const window = app_kit.Window.alloc().initWithContentRectStyleMaskBackingDefer(
rect,
style_mask,
app_kit.BackingStoreType_Retained,
.NO,
);
// Allocate a string and set the title of the window
const title = foundation.String.alloc().initWithUTF8String("Hello World");
window.setTitle(title);
// Show the window and bring out.
window.makeKeyAndOrderFront(null);
// Run the event loop
app.run();
}
Contributions are welcome! Feel free to open issues or submit pull requests if you want to help improve the project.
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the Zig community for their ongoing support and inspiration
- Inspiration for this project comes from the ened to bridge the gap between Zig and the Objective-C ecosystem.
- Mach and mach-objc for giving me the initial inspiration, resources, and some runtime code bindings.