Skip to content

iOS/tvOS/watchOS/visionOS support in framework crates #408

@madsmtm

Description

@madsmtm

My plan was to do something like:

  1. Run the "collection" part of header-translator (e.g. main.rs::parse_sdk) for each platform
  2. Compare the output against each other:
  • For each framework, if it exists on one platform but not the others, add it to the list of frameworks, but with appropriate availability attribute that will end up adding a cfg attribute on it
  • For each file, --||--
  • On each platform, put all statements into some sort of HashMap with "top-level" information (name of stmt, which generics a class has, and so on (but not which methods a class has implemented))
    • Use this to figure out which statements are on which some platforms
      • Add that to the final output, with relevant cfg attributes (ideally in the same order as the input file)
  • Similarly for each method in classes/protocols/categories
  1. Output the combined result

The result is that we would only have to distribute one crate, and that crate would have the correct cfg attributes, which is very useful for the documentation on docs.rs (since it could directly show us which things are available on which platforms).

As an example, let's take NSPointerArray: On this, there are five methods on macOS, and three on iOS, pointerArrayWithStrongObjects and pointerArrayWithWeakObjects are only available on iOS. So the result we'd like is that these two got a #[cfg(target_os = "macos")] on them.


All of this is the ideal solution; before we get there though, we're going to be doing a bunch of hacks, #600 contains an example of one of these.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frameworkAffects the framework crates and the translator for themhelp wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions