Skip to content

Hide Objective-C nature of XML and HTML body deserializers #42

@akashivskyy

Description

@akashivskyy

As libxml cannot be imported to Swift directly, ResponseDetective currently uses RDTBodyDeserializer, RDTXMLBodyDeserializer and RDTHTMLBodyDeserializer types, thus making its unwanted Objective-C nature public.

Ideally, I'd like to remove all traces of Objective-C files from the project. This could be achieved in a couple of ways:

  1. Use an Objective-C libxml wrapper as an external framework and import it directly in Swift. This is the worst solution because it adds an unwanted third-party dependency to ResponseDetective.

  2. Create a project-private libxml wrapper as a separate framework and import it directly in Swift. This is better than the 1st solution, but adds a lot of unwanted complexity, especially with header search paths, linking and module maps.

  3. Use a project-private module (not to be mistaken with framework) that exposes needed libxml functionalities internally to ResponseDetective, but no further. This is the best solution.

Assuming the 3rd solution is chosen, the proposed implementation would consist of the following files:

  • A .m file that uses libxml and contains implementation of XML and HTML pretty-printing,
  • A non-public .h file that contains interface of above implementation,
  • A .modulemap file that defines a module including the above header.

As a result, ResponseDetective could import XMLPrettyPrinting (exemplary name of module) directly and use refined-for-Swift APIs without them leaking to the outside world.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions