{"id":26648100,"url":"https://github.com/progrium/macdriver","last_synced_at":"2026-01-16T03:36:07.995Z","repository":{"id":38015245,"uuid":"309781884","full_name":"progrium/darwinkit","owner":"progrium","description":"Native Mac APIs for Go. Previously known as MacDriver","archived":false,"fork":false,"pushed_at":"2025-03-08T16:47:06.000Z","size":9011,"stargazers_count":5160,"open_issues_count":35,"forks_count":164,"subscribers_count":46,"default_branch":"main","last_synced_at":"2025-03-19T12:21:13.618Z","etag":null,"topics":["appkit","apple","apple-apis","bindings","bridge","cgo","cocoa","coremidi","coreml","go","golang","ios","libobjc","mac","macos","macos-application","native-apps","objc-runtime","objective-c","webkit"],"latest_commit_sha":null,"homepage":"","language":"Go","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/progrium.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"darwinkitdev"}},"created_at":"2020-11-03T19:04:37.000Z","updated_at":"2025-03-17T21:55:42.000Z","dependencies_parsed_at":"2024-07-15T23:41:14.893Z","dependency_job_id":"0ea82a5c-3e14-4744-b4f9-f09de26ff6f2","html_url":"https://github.com/progrium/darwinkit","commit_stats":{"total_commits":209,"total_committers":20,"mean_commits":10.45,"dds":0.4114832535885168,"last_synced_commit":"32e7360ca836dddaa9e3eed4659323e328eb9643"},"previous_names":["progrium/go-macdriver","progrium/macdriver"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fdarwinkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fdarwinkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fdarwinkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fdarwinkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/progrium","download_url":"https://codeload.github.com/progrium/darwinkit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245372377,"owners_count":20604491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["appkit","apple","apple-apis","bindings","bridge","cgo","cocoa","coremidi","coreml","go","golang","ios","libobjc","mac","macos","macos-application","native-apps","objc-runtime","objective-c","webkit"],"created_at":"2025-03-25T00:01:22.929Z","updated_at":"2025-03-25T00:01:53.491Z","avatar_url":"https://github.com/progrium.png","language":"Go","readme":"\u003cimg alt=\"DarwinKit Logo\" src=\"https://github.com/progrium/darwinkit/raw/main/darwinkit.png\" style=\"height:125px;\" /\u003e\n\nNative Apple APIs for Golang!\n\n\n\n\n[![GoDoc](https://godoc.org/github.com/progrium/darwinkit?status.svg)](https://pkg.go.dev/github.com/progrium/darwinkit@main)\n[![Go Report Card](https://goreportcard.com/badge/github.com/progrium/darwinkit)](https://goreportcard.com/report/github.com/progrium/darwinkit)\n\u003ca href=\"https://twitter.com/progrium\" title=\"@progrium on Twitter\"\u003e\u003cimg src=\"https://img.shields.io/badge/twitter-@progrium-55acee.svg\" alt=\"@progrium on Twitter\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/progrium/darwinkit/discussions\" title=\"Project Forum\"\u003e\u003cimg src=\"https://img.shields.io/badge/community-forum-ff69b4.svg\" alt=\"Project Forum\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/sponsors/darwinkitdev\" title=\"Sponsor Project\"\u003e\u003cimg src=\"https://img.shields.io/static/v1?label=sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\" alt=\"Sponsor Project\" /\u003e\u003c/a\u003e\n\n\u003e [!IMPORTANT]\n\u003e July 11, 2024: **MacDriver is now DarwinKit!** You can also now get high-quality example starter apps when you [support the project as a sponsor](https://github.com/sponsors/darwinkitdev).\n\n------\n\n![ScanDrop Demo](https://github.com/progrium/darwinkit/assets/1813419/e66e4ca1-af6b-4952-9e53-f10ab436993f)\n![SnowScape Demo](https://github.com/progrium/darwinkit/assets/1813419/3b04b849-4292-41c5-8563-7735ff46c745)\n![MenuSpacer Demo](https://github.com/progrium/darwinkit/assets/1813419/ed86724d-f1fc-42e4-b9c9-0112fffd86fc)\n![ClipTrail Demo](https://github.com/progrium/darwinkit/assets/1813419/c018851d-5af7-4cf6-8e21-213c28752438)\n\n\nDarwinKit lets you work with [supported Apple frameworks](https://pkg.go.dev/github.com/progrium/darwinkit/macos@main#section-directories) and build native applications using Go. With XCode and Go 1.18+ installed, you can write this program in a `main.go` file:\n\n```go\npackage main\n\nimport (\n\t\"github.com/progrium/darwinkit/objc\"\n\t\"github.com/progrium/darwinkit/macos\"\n\t\"github.com/progrium/darwinkit/macos/appkit\"\n\t\"github.com/progrium/darwinkit/macos/foundation\"\n\t\"github.com/progrium/darwinkit/macos/webkit\"\n)\n\nfunc main() {\n\t// runs macOS application event loop with a callback on success\n\tmacos.RunApp(func(app appkit.Application, delegate *appkit.ApplicationDelegate) {\n\t\tapp.SetActivationPolicy(appkit.ApplicationActivationPolicyRegular)\n\t\tapp.ActivateIgnoringOtherApps(true)\n\n\t\turl := foundation.URL_URLWithString(\"https://github.com/sponsors/darwinkitdev\")\n\t\treq := foundation.NewURLRequestWithURL(url)\n\t\tframe := foundation.Rect{Size: foundation.Size{1440, 900}}\n\n\t\tconfig := webkit.NewWebViewConfiguration()\n\t\twv := webkit.NewWebViewWithFrameConfiguration(frame, config)\n\t\twv.LoadRequest(req)\n\n\t\tw := appkit.NewWindowWithContentRectStyleMaskBackingDefer(frame,\n\t\t\tappkit.ClosableWindowMask|appkit.TitledWindowMask,\n\t\t\tappkit.BackingStoreBuffered, false)\n\t\tobjc.Retain(\u0026w)\n\t\tw.SetContentView(wv)\n\t\tw.MakeKeyAndOrderFront(w)\n\t\tw.Center()\n\n\t\tdelegate.SetApplicationShouldTerminateAfterLastWindowClosed(func(appkit.Application) bool {\n\t\t\treturn true\n\t\t})\n\t})\n}\n\n```\n\nThen in this directory run:\n\n```\ngo mod init helloworld\ngo get github.com/progrium/darwinkit@main\ngo run main.go\n```\n\nThis may take a moment the first time, but once the window pops up you just made a macOS program without using XCode or Objective-C. Run `go build` to get an executable. \n\nAlthough currently outside the scope of this project, if you wanted you could put this executable [into an Application bundle](https://stackoverflow.com/a/3251285). You could even add [entitlements](https://developer.apple.com/documentation/bundleresources/entitlements?language=objc), then [sign and notarize](https://developer.apple.com/support/code-signing/) this bundle or executable to let others run it. It could theoretically even be put on the App Store. It could *theoretically* be put on an iOS, tvOS, or watchOS device, though you would have to use different platform specific frameworks.\n\n### Caveats\n\n* You still need to know or learn how Apple frameworks work, so you'll have to use Apple documentation and understand how to translate Objective-C example code to the equivalent Go with DarwinKit.\n* Your programs link against the actual Apple frameworks using [cgo](https://pkg.go.dev/cmd/cgo), so XCode needs to be installed for the framework headers.\n* You will be using two memory management systems. Framework objects are managed by [Objective-C memory management](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html#//apple_ref/doc/uid/10000011-SW1), so be sure to read our docs on [memory management](docs/memorymanagement.md) with DarwinKit.\n* Exceptions in frameworks will segfault, giving you both an Objective-C stacktrace and a Go panic stacktrace. You will be debugging a hybrid Go and Objective-C program.\n* Goroutines that interact with GUI objects need to [dispatch](https://pkg.go.dev/github.com/progrium/darwinkit@main/dispatch) operations on the main thread otherwise it will segfault.\n\nThis is all tenable for simple programs, but these are the reasons we don't *recommend* large/complex programs using DarwinKit.\n\n## Examples\n\nThere are basic usage examples [here in this repo](./macos/_examples), but there are higher-quality full utilities you can use as examples or starter templates [when you sponsor](https://github.com/sponsors/darwinkitdev).\n\n![LargeType Demo](https://github.com/progrium/darwinkit/assets/1813419/b54a8015-dfef-40ce-bc56-f75cb8455306)\n![ScanDrop Demo](https://github.com/progrium/darwinkit/assets/1813419/e66e4ca1-af6b-4952-9e53-f10ab436993f)\n![SnowScape Demo](https://github.com/progrium/darwinkit/assets/1813419/3b04b849-4292-41c5-8563-7735ff46c745)\n![LiveTemp Demo](https://github.com/progrium/darwinkit/assets/1813419/c57cd196-3ff6-4068-bd0a-05b9283d199d)\n![MenuSpacer Demo](https://github.com/progrium/darwinkit/assets/1813419/ed86724d-f1fc-42e4-b9c9-0112fffd86fc)\n![ClipTrail Demo](https://github.com/progrium/darwinkit/assets/1813419/c018851d-5af7-4cf6-8e21-213c28752438)\n![FocusTimer Demo](https://github.com/progrium/darwinkit/assets/1813419/9e14fe2f-88a9-4b89-9f9c-a305fb103d4c)\n\n\n## How it works\n\n\u003cdetails\u003e\n\u003csummary\u003eBrief background on Objective-C\u003c/summary\u003e\n\t\nEver since acquiring NeXT Computer in the 90s, Apple has used [NeXTSTEP](https://en.wikipedia.org/wiki/NeXTSTEP) as the basis of their software stack, which is written in Objective-C. Unlike most systems languages with object orientation, Objective-C implements OOP as a runtime library. In fact, Objective-C is just C with the weird OOP specific syntax rewritten into C calls to [libobjc](https://developer.apple.com/documentation/objectivec/objective-c_runtime?language=objc), which is a normal C library implementing an object runtime. This runtime could be used to bring OOP to any language that can make calls to C code. It also lets you interact with objects and classes registered by other libraries, such as the Apple frameworks. \n\n\u003c/details\u003e\n\nAt the heart of DarwinKit is a package wrapping the Objective-C runtime using [cgo](https://pkg.go.dev/cmd/cgo) and [libffi](https://github.com/libffi/libffi). This is actually all you need to interact with Objective-C objects and classes, it'll just look like this:\n\n```go\napp := objc.Call[objc.Object](objc.GetClass(\"NSApplication\"), objc.Sel(\"sharedApplication\"))\nobjc.Call[objc.Void](app, objc.Sel(\"run\"))\n```\n\nSo we wrap these calls in a [Go API](docs/bindings.md) that lets us write code like this:\n\n```go\napp := appkit.Application_SharedApplication()\napp.Run()\n```\n\nThese bindings are great, but we need to define them for every API we want to use. Presently,\nApple has around 200 frameworks of nearly 5000 classes with 77k combined methods and properties. Not to \nmention all the constants, functions, structs, unions, and enums we need to work with those objects.\n\nSo DarwinKit generates its bindings. This is the hard part. Making sure the generation pipeline accurately produces usable bindings for all possible symbols is quite an arduous, iterative, manual process. Then since we're moving symbols that lived in a single namespace into Go packages, we have to manually decouple dependencies between them enough to avoid circular imports. If you want to help add frameworks, read our documentation on [generation](docs/generation.md).\n\nObjects are passed around as typed pointer values in Objective-C. When we receive an object from a method\ncall in Go, the `objc` package receives it as a raw pointer, which it first puts into an `unsafe.Pointer`. The\nbindings for a class define a struct type that embeds an `objc.Object` struct, which contains a single\nfield to hold the `unsafe.Pointer`. So unless working with a primitive type, you're working with an `unsafe.Pointer` wrapped in an `objc.Object` wrapped in a struct type that has the methods for the class of the object of the pointer. Be sure to read our documentation on [memory management](docs/memorymanagement.md).\n\nIf you have questions, feel free to ask in the [discussion forums](https://github.com/progrium/darwinkit/discussions).\n\n## Thanks\n\nThis project was inspired by and originally based on packages written by [Mikkel Krautz](https://github.com/mkrautz). The latest version is based on packages written by [Dong Liu](https://github.com/hsiafan).\n\n## Notice\n\nThis project is not affiliated or supported by Apple.\n\n## License\n\nMIT\n","funding_links":["https://github.com/sponsors/darwinkitdev"],"categories":["开源类库","Go","Open source library","Repositories"],"sub_categories":["桌面开发","Desktop Development"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrium%2Fmacdriver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogrium%2Fmacdriver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrium%2Fmacdriver/lists"}