{"id":13806044,"url":"https://github.com/magic003/objc","last_synced_at":"2026-01-19T09:03:22.360Z","repository":{"id":193550367,"uuid":"685092403","full_name":"magic003/objc","owner":"magic003","description":"V bindings to Objective-C runtime.","archived":false,"fork":false,"pushed_at":"2024-07-12T05:17:45.000Z","size":1007,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-13T21:42:17.316Z","etag":null,"topics":["bindings","objective-c","vlang","vlang-package"],"latest_commit_sha":null,"homepage":"","language":"V","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magic003.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-30T13:55:51.000Z","updated_at":"2025-05-05T21:11:16.000Z","dependencies_parsed_at":"2023-09-08T17:58:01.337Z","dependency_job_id":"89a30f71-0cce-40fe-ab43-d38b1b2dc662","html_url":"https://github.com/magic003/objc","commit_stats":null,"previous_names":["magic003/objc"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/magic003/objc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magic003%2Fobjc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magic003%2Fobjc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magic003%2Fobjc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magic003%2Fobjc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magic003","download_url":"https://codeload.github.com/magic003/objc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magic003%2Fobjc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28565001,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T08:53:44.001Z","status":"ssl_error","status_checked_at":"2026-01-19T08:52:40.245Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bindings","objective-c","vlang","vlang-package"],"created_at":"2024-08-04T01:01:07.367Z","updated_at":"2026-01-19T09:03:22.341Z","avatar_url":"https://github.com/magic003.png","language":"V","funding_links":[],"categories":["Libraries"],"sub_categories":["Utility"],"readme":"This vlang package provides Objective-C Runtime bindings for V.\n\n## Status\nIt is currently work in progress and should be considered experimental. It's tested on \nx86\\_64 and arm64 (Apple Silicon) architectures, macOS Sonoma 14.5.\n\nSupported features:\n* Bool type\n* Id type\n* Load classes\n* Create instances\n* Register selectors\n* Send messages (varargs are not supported)\n* Class declaration\n\n## Installation\n```shell\nv install magic003.objc\n```\n\n## Usage\n\n### Bool type\nThe `Bool` type is an alias of the V `bool` type.\n\n```v\nassert objc.yes == true\nassert objc.no == false\n```\n\n### Load a class\nAn Objective-C class can be loaded using either a factory function or a static type method.\n\n```v\ncls1 := objc.Class.get('NSMutableArray') or { panic('failed to load class NSMutableArray') }\ncls2 := objc.class('NSMutableArray') or { panic('failed to load class NSMutableArray') }\n```\n\n### Register and get a selector\nAn Objective-C selector can be registered using either a factory function or a static type method.\n\n```v\ns1 := objc.Sel.get('init')\ns2 := objc.sel('init')\n```\n\n### Send messages\nMessages can be sent to a class or an instance. There are two types of messages:\n* `request[R]()`: a message with return type `R`.\n* `notify()`: a message without a return value.\n\n```v\nunsafe {\n    // a mutable array instance is created via chained messages\n    arr := cls1.message(objc.sel('alloc')).request[objc.Id]()\n            .message(objc.sel('init')).request[objc.Id]()\n\n    // load the NSObject class and create an instance\n    obj_cls := objc.class('NSObject') or { panic('failed to load class NSObject') }\n    obj := obj_cls.message(sel('new')).request[objc.Id]()\n\n    // add an object to the array. Message with one argument and no return value. \n    // Use `args2()`, `args3()` and etc for more arguments.\n    arr.message(sel('addObject:')).args1(obj).notify()\n\n    // message without an argument.\n    size := arr.message(sel('count')).request[u64]()\n    assert size == 1\n}\n```\n\n### Declare a new class\nNew classes can be declared and registered with the Objective-C Runtime.\n\n```v\nsuperclass := objc.class('NSObject') or { panic('failed to load class NSObject') }\n// create a new class with `NSObject` as the super class.\ndecl := ClassDecl.new(superclass, 'NewClass', 0) or {\n    panic('failed to create class NewClass')\n}\n\n// add ivars\ndecl.add_ivar[i64]('num')\ndecl.add_ivar[objc.Id]('obj')\n\n// add methods\nm1 := objc.void_method_1[bool](fn (self objc.Id, cmd objc.Sel, flag bool) {\n    // do something\n})\nunsafe { decl.add_method(objc.sel('method1:'), m1) }\nm2 := objc.method_1[int, objc.Id](fn (self objc.Id, cmd objc.Sel, obj objc.Id) int {\n    return 10\n})\nunsafe { delc.add_method(objc.sel('method2:'), m2) }\n\n// register the class\ncls := decl.register()\n\nunsafe {\n    // create an instance from the new class\n    obj := cls.message(objc.sel('new')).request[objc.Id]()\n    \n    // set ivar\n    obj.set_ivar('num', 1)\n\n    // call method\n    obj.message(objc.sel('method1:')).args1(true).notify()\n}\n```\n\n## Examples\n\nThe unit tests have basic usages.\n\nCheck out the `examples` folder for more examples. \n\n## Documentation\n\n* API Documentation: http://magic003.github.io/objc\n* Why this project: [V and Objective-C interoperability](https://open.substack.com/pub/insideout101/p/v-and-objective-c-interoperability?r=2rxz0s\u0026utm_campaign=post\u0026utm_medium=web)\n\n## References\n\n* [Programming with Objective-C](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC) \n* [Objective-C Runtime APIs](https://developer.apple.com/documentation/objectivec?language=objc)\n* [rust-objc](https://github.com/SSheldon/rust-objc): Objective-C bindings for Rust.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagic003%2Fobjc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagic003%2Fobjc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagic003%2Fobjc/lists"}