0

I have developed an iOS App and would like to create a web API with some parts of my code. This API will send an UIImage generated from a UIView. The problem I have with Vapor is that I only managed to use AppKit, not UIKit. Certainly because the Xcode project with Vapor is a MacOS project. Is there a way to use UIKit or iOS Swift code with Vapor or any other solutions like Kitura ???

Thanks for your help :)

Regards,

Adz
  • 281
  • 3
  • 16
  • "create a web API with some parts of my code" ... it is possible for some Swift code reuse across the iOS/Linux/macOS/ platforms. The key is to _separate platform specific elements_ (e.g. UIView, NSView, Vapor View) from reuseable Swift code which is build on the cross platform Swift Foundation. The reuseable cross platform Swift code can then be used in a Swift Package on all platforms. See [Vapor server and companion iOS app examples](https://stackoverflow.com/questions/47717355/vapor-server-and-companion-ios-app-examples/55368410#55368410) – marc-medley Apr 02 '19 at 18:51

1 Answers1

2

If you want your Backend API Server (Vapor or Kitura) to run in a hosted environment, it will need to be able to run on Linux - where only Foundation is supported.

You can still transfer UIImages between iOS app and server, but you'll need to convert the UIImage to Data first (using something like UIImage.jpegData())

You can see an example of this in the "FoodTrackerBackend" tutorial for Kitura here: https://github.com/IBM/FoodTrackerBackend

Chris Bailey
  • 292
  • 1
  • 3