Skip to content

The future of the Objective-C crate ecosystem #101

Open
@madsmtm

Description

@madsmtm

Introduction

Hey @SSheldon, I really like your collection of Objective-C crates:

For better discoverability, maintainability, interoperability and usability (I will get to each of these), I would like to propose moving objc-encode, objc_exception, objc_id and objc-foundation (and maybe block and uikit? But probably not dispatch) into this repository.

Discoverability

objc (and by extension, it's dependencies) is popular and therefore easily discoverable, but we should strive to make the other crates receive some 👀 as well.

As you noted in SSheldon/rust-objc-id#4 (comment):

Not having wider adoption has slowed it down

As a very concrete example, I reimplemented almost the entirety of objc_id in #98 before realising that it existed.

Maintainability

We might want to change Sel to be an opaque struct like most of the other types, or add UnwindSafe bound to objc_exception::try - Making these changes are far easier to coordinate in a "monorepo".

Also, if a better way to do a general thing is discovered, it can easily be applied everywhere - for example e86d26a (making stuff opaque structs instead of uninhabited enums) haven't been done in objc_exception (see SSheldon/rust-objc-exception#9).

Finally, we'd only need to maintain stuff like CI in one place.

Interoperability

A lesser point, since objc-encode, objc_exception, objc and objc_id all form a dependency graph, but block for example needs Class but has to create it's own type to not depend on objc.

Also, it would be cool if Id<Block, Owned>/Id<Block, Shared> instead of RcBlock was a thing, that might be able to make Block::call (+ Block::call_mut) and impl FnMut/Fn for Block safe.

Usability

Users don't want to consider all the above crates, and whether they're fit for their use cases; e.g. winit reimplements objc_foundation::NSString and objc::rc::StrongPtr, partially for historical reasons, but I suspect also because there haven't been a clear user story on how to to these higher-level things.

fruity exists for a reason; users want easy and safe. (Though I think @nvzqz took the wrong approach creating everything from scratch, I'll probably contact them at some point in the future to see if we can combine efforts).

Concrete implementation

Make this a cargo workspace like core-foundation-rs, and move the crates in here (and maybe for objc_id just merge it into the objc crate?).

Additionally, we should make some more cargo features to make it easy to choose which parts of the library to compile (e.g. an rc feature, a message feature and so on).

I can make the PRs, but you'll have to mark the old repositories as archived and such.

Drawbacks and alternatives

  • Git history (solvable) and GitHub issues (less so) would get mangled up.
  • There's less room for exploration, having something as a separate crate let's you easier (also solvable, we could have "unstable_x" features or just have the crate in the workspace).
  • The discoverability issue could be mitigated with better linking to the different repositories in documentation.

Outtro

We can talk about it over a quicker medium if you prefer.

Also, if you're loosing interest in the project(s) and need a hand with the maintainer role, I'll gladly help out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions