Swiftpack.co - jectivex/JXBridge as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by jectivex.
jectivex/JXBridge 0.2.1
Bridge Swift and ObjectiveC classes and structs for use with JXKit.
⭐️ 1
🕓 1 year ago
iOS macOS tvOS
.package(url: "https://github.com/jectivex/JXBridge.git", from: "0.2.1")

JXBridge

Build Status Swift5 compatible Platform

Bridge ObjectiveC and Swift classes and structs with JavaScript using JXKit.

API

Browse the API Documentation.

Dependencies

  • JXKit: Cross-platform JavaScript engine[^1]

TODO

  • Formalize threading model.

    • We currently assume that there is never concurrent access to a JXContext.
    • We always evaluate JavaScript - including calling any bridged native code - on the context's calling thread.
  • Support mode in which all JS executes on a given background queue and hops to another queue for native code.

  • Support native Actors and perform async calls.

  • Add JXContext.current for native code called from JS.

  • Support Swift delegates in JavaScript.

    • I don't think there's any way to get around requiring the developer to write an implementing of the delegate protocol. But we may be able to give her a simple API with which to invoke the corresponding JS code for each delegate callback. E.g.:

        func sender(_ sender: Sender, didSomethingWithResult result: Result) -> Return {
            return jsDelegate.invoke('senderDidSomethingWithResult', [sender, result]).convey(to: Return.self)
        }
      
  • Consider a SourceKit plugin option to auto-generate Swift bridging code.

  • Test enhancing and overriding reflected ObjectiveC API with explicit bridging.

  • Support ObjectiveC trailing error: NSError** parameters.

    • We can detect this from the selector name and type encoding (^@ is an object pointer) and convert to a throwing function.
  • Support ObjectiveC delegates in JavaScript.

    • We should be able to create the delegate at runtime and call through to the underlying JavaScript code.
  • Support ObjectiveC trailing blocks in JavaScript.

    • ObjectiveC reflection does not give you any information about block signatures. In fact the type encoding is just 'unsupported' (?).
  • Consider implementing ObjectiveC reflected API using a JavaScript Proxy rather than writing out a full class definition.

    • Proxys do not handle static API well.

GitHub

link
Stars: 1
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics