Skip to content

Rewrite cocoa crate to mirror Swift APIs instead of ObjC APIs #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Tracked by #719
mehcode opened this issue Nov 26, 2018 · 3 comments
Open
Tracked by #719

Rewrite cocoa crate to mirror Swift APIs instead of ObjC APIs #278

mehcode opened this issue Nov 26, 2018 · 3 comments

Comments

@mehcode
Copy link
Contributor

mehcode commented Nov 26, 2018

Refs #200


Thoughts on this? These crates are frustrating to use in Rust. Adapting the Swift APIs would lead to a significantly better UX in the API.

We could offer the Objective C API in addition to the Swift API for some backwards compatibility though I'm unsure if we could keep it 100% as the types are just id aliases now.

@jdm
Copy link
Member

jdm commented Nov 26, 2018

Can you give some examples of before and after? Which APIs are you referring to?

@mehcode
Copy link
Contributor Author

mehcode commented Nov 28, 2018

By mirror Swift APIs I don't mean use the names and types that Swift does. I more meant use the approach that Swift took in wrapping Objective C and take liberty with naming and types to better match our host language, Rust.

Naming

As an example.. instead of NSWindowStyleMask::NSClosableWindowMask, we could have WindowStyleMask::CLOSABLE; instead of, window.makeKeyAndOrderFront_(nil) we could have window.make_key_and_order_front(None).

Safety

Nearly every line of cocoa code I write needs an unsafe { .. } block when its mostly "safe" in theory. We should be able to enforce safety.

I see there was some interest in #200.


It looks like there have been a couple of attempts elsewhere to make things nicer, like in objrs.


I don't really have a definitive plan. More just musing and would love to contribute to an effort to have a better overall native iOS/macOS dev experience in Rust.

@lqf96
Copy link
Contributor

lqf96 commented Nov 13, 2019

Just a random thought: we should leverage the toll-free bridging between Objective-C, Swift and CoreFoundation types in some way to minimize the work we need to do. This will also make interaction with Swift code easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants