Sharing Swift Code Between iOS and Server Applications

In this tutorial, you’ll learn how share code between iOS and server applications. By Christian Weinberger.

Leave a rating/review
Download materials
Save for later
Share
You are currently viewing page 4 of 4 of this article. Click here to view the first page.

Cleaning Up

Stop your Vapor project to stop the Vapor server.

To stop the PostgreSQL database, head to the Terminal window where docker-compose is still running, and type Control-C.

To remove the images and containers created by docker-compose, in Terminal, in the same directory as your docker-compose file, run:

docker-compose down -v --rmi all --remove-orphans

Where to Go From Here?

You can download the completed project files by clicking the Download Materials button at the top or bottom of the tutorial.

In this article, you’ve learned how to create a library to share Swift code between server-side apps and iOS apps! You’ve built a shared library using SwiftPM. You’ve also learned how to integrate the library into an iOS app and a Server-Side Swift app.

Now that you have code shared between two different apps, try adding new properties to the models and see how easy it is to keep them working together.

If you’re looking for a challenge beyond the scope of this article, here are a couple things you can try:

  • Migrate Endpoints to the shared package, similar to what you did with the API models.
  • Share TILError from the Vapor project with iOS.

To learn more about Server-Side Swift and Vapor, check out:

We hope you enjoyed this tutorial. If you have any questions, comments or ideas on what else to share between iOS and Vapor, please join the forum discussion below!