zserge / tray

Cross-platform, super tiny C99 implementation of a system tray icon with a popup menu.
MIT License
493 stars 84 forks source link

macOS version re-written with objc-runtime #4

Closed jslegendre closed 5 years ago

jslegendre commented 5 years ago

All Objective-C has been replaced with C using ObjC Runtime. The section was completely re-written with the goal of not needing to include the Cocoa headers as some compilers/static analyzers/linters mistake the headers for errors.

A fortunate side-effect of this is the '-x objective-c' flag is no longer needed to compile.

zserge commented 5 years ago

@jslegendre Awesome job, thank you! Wanted to do this for a long time. Did you do any automation (tools/scripts) or did it manually?

jslegendre commented 5 years ago

@zserge No problem! I enjoy contributing. I did this manually. I think at this point I have written more C in objc-runtime than I have actual Objective-C so it was mostly no problem.

Let me know if any changes need to be made!

zserge commented 5 years ago

I am asking because I have a similar cross-platform project, https://github.com/zserge/webview and it has similar issues with ObjC. But it has much more ObjC code in there, and it's still being changed often. So I was looking for an automated way to convert ObjC to objc-runtime at some point.

jslegendre commented 5 years ago

@zserge I am not familiar with any build systems that do this currently. I think the best way to handle that situation is to write in objective-c until you have an API locked in and then do a re-write. It's a pain but I think it is less painful than constantly re-writing C with objc-runtime calls.

I'd be happy to contribute what I can to webview. Let me know what I can do!