Search code examples
javaiosswift

Is there a way to get Apple's Swift language interacting with Java?


I've been given a Java API for my personal project. This means that all of the method calls and functions to utilize the API are in the Java programming language. However, I want to use Apple's new Swift language to create an iOS application that uses the API. So my question is as follows:

How can I get Apple's Swift language to interact with Java within XCode? In short, I want a button press in the Swift app to use the Java methods within the given API which will then create a file on a remote server and send it back to the device.

Any help would be greatly appreciated.


Solution

  • You can always write web services in Java and let Swift UI invoke them via HTTP. The separates the services from your UI and keeps that functionality available for others to use as well.

    This means that the web services are deployed separately. Your UI will send a request via HTTP and send it back to the device. All the details about files or databases or how the data is derived are hidden from the client.