[go: up one dir, main page]

Skip to content

PureSwift/swift-java

 
 

Repository files navigation

Swift Java Interoperability Tools and Libraries

This repository contains two approaches to Swift/Java interoperability.

  • A Swift library (JavaKit) and bindings generator that allows a Swift program to make use of Java libraries by wrapping Java classes in corresponding Swift types, allowing Swift to directly call any wrapped Java API.
  • The jextract-swift tool which is similar to the JDK's jextract which allows to extract Java sources which are used to efficiently call into Swift from Java.

🚧 🚧 🚧 Early Development 🚧 🚧 🚧

🚧 🚧 🚧 This is a very early prototype and everything is subject to change. 🚧 🚧 🚧

Parts of this project are incomplete, not fleshed out, and subject to change without any notice.

The primary purpose of this repository is to create an environment for collaboration and joint exploration of the Swift/Java interoperability story. The project will transition to a more structured approach once key goals have been outlined.

Development and Testing

This project contains quite a few builds, Swift, Java, and depends on some custom steps.

Easiest way to get going is to:

make
swift test # test all Swift code, e.g. jextract-swift
./gradlew test # test all Java code, including integration tests that actually use jextract-ed sources

Examples

JavaKit (Swift -> Java)

To run a simple app showcasing a Swift process calling into a Java library you can run:

make run

Which executes a small Java app (com.example.swift.HelloSwift).

jextract (Java -> Swift)

To run a simple example app showcasing the jextract (Java calling Swift) approach you can:

make jextract-run
./gradlew run

which will run JavaSwiftKitDemo sample app.

User Guide

More details about the project and how it can be used are available in USER_GUIDE.md

Releases

No releases published

Packages

No packages published

Languages

  • C 86.7%
  • Swift 11.5%
  • Java 1.6%
  • Other 0.2%