Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Hands-On Swift 5 Microservices Development
Hands-On Swift 5 Microservices Development

Hands-On Swift 5 Microservices Development: Build microservices for mobile and web applications using Swift 5 and Vapor 4

Arrow left icon
Profile Icon Ralph Kuepper
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3 (6 Ratings)
Paperback Mar 2020 392 pages 1st Edition
eBook
NZ$34.99 NZ$38.99
Paperback
NZ$48.99
Subscription
Free Trial
Arrow left icon
Profile Icon Ralph Kuepper
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3 (6 Ratings)
Paperback Mar 2020 392 pages 1st Edition
eBook
NZ$34.99 NZ$38.99
Paperback
NZ$48.99
Subscription
Free Trial
eBook
NZ$34.99 NZ$38.99
Paperback
NZ$48.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Hands-On Swift 5 Microservices Development

Understanding Server-Side Swift

Swift is a very young language as it was just released in 2014. It was designed to be a language with an easy syntax but that is as powerful as C. In this chapter, you are going to learn why Swift is an excellent choice when it comes to developing server applications. Swift arrives as a fresh alternative to all current and established solutions.

This chapter will introduce you to the server side of Swift; the basic understanding of Swift itself is something you should be familiar with already. At first, you are going to look at Swift as a generic language and why it fits well into the server world. Afterward, we look at the performance Swift delivers compared to other web technologies. A review of the current state of Swift for servers and an introduction to the new features of Swift 5 will sum this chapter up.

The following topics will be covered in this chapter:

  • A quick review of Swift
  • Swift performance
  • Swift on the server
  • The features of Swift 5

Once you have read this chapter, you will be well prepared to start using Swift for your application.

Technical Requirements

A quick review of Swift

To write server apps in Swift, we require an understanding of where Swift comes from and how it fits into the world of server languages. Swift was invented by Apple engineers as an alternative to C-derivatives, for example, C++, and, Objective-C, Objective-C++. After initially keeping Swift proprietary Apple then released Swift as open source for macOS and Linux. You might have wondered why Apple would bother to make Swift available on Linux, as Apple doesn't usually release any Linux products (not even iTunes).

Swift was designed to be a native language from the very beginning. It means an application gets compiled into binary code that runs directly on the processor, making it the fastest way for an application to run.

When Apple released Swift for Linux, there was little application. The UI was still functioning only on Apple devices, but a good bit of the essential frameworks, Foundation, in particular, was functional on Linux. These frameworks opened the door for some early web frameworks that took Swift and connected it to C libraries that would allow Swift code to run as a web server.

The Perfect framework was the first framework that did this. In September 2016, Tanner Nelson wrote the first version of the Vapor framework, which was loosely based on the Laravel framework (PHP). In May 2017, Vapor 2 was released, which was the first Swift framework that didn't rely on a C library to provide web server functionality. In the meanwhile, IBM started to work on Kitura, yet another framework allowing Swift to be used for web applications.

In early 2018, Apple released SwiftNIO, which is a network library for Swift. You can think of it as "Netty for Swift" if you are familiar with Netty (Java). To put it simply: SwiftNIO provides a very foundational framework to operate in a network and in files, such as opening connections, sending data, receiving data, sending streams, reading streams, and similar operations.

By releasing SwiftNIO, Apple now gave developers an essential set of features to work on server applications. SwiftNIO, like Swift, was also released for Linux.

While Swift has so far been released for macOS and Linux only, work-in-progress versions of Swift and SwiftNIO for Android, Windows, and other platforms exist. While Apple has not announced any plans for support, as an open source project, Swift and NIO can undoubtedly grow in maturity on other platforms. Swift on Linux runs on all available Linux flavors, though only Ubuntu is officially supported.

Let's take a brief look at the history of Swift in the context of other programming languages.

From Fortran to Swift

In this section, we want to take a look at the development of Swift, from Fortran, a very old programming language, up until Swift.

The following diagram and the timeline next to it highlights well how Swift combines the best of numerous worlds:

It stands out that Swift was influenced by Rust, Ruby, Python, Haskel, and C#, making it a very modern language that copied some of the most loved features of the other languages.

Now, we have learned about the history of Swift and where its place is in the world of programming languages. Let's look at Swift's performance compared to other popular web technologies next.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Understand server-side Swift development concepts for building your first microservice
  • Build microservices using Vapor 4 and deploy them to the cloud using Docker
  • Learn effective techniques for enhancing maintainability and stability of your Swift applications

Description

The capabilities of the Swift programming language are extended to server-side development using popular frameworks such as Vapor. This enables Swift programmers to implement the microservices approach to design scalable and easy-to-maintain architecture for iOS, macOS, iPadOS, and watchOS applications. This book is a complete guide to building microservices for iOS applications. You’ll start by examining Swift and Vapor as backend technologies and compare them to their alternatives. The book then covers the concept of microservices to help you get started with developing your first microservice. Throughout this book, you’ll work on a case study of writing an e-commerce backend as a microservice application. You’ll understand each microservice as it is broken down into details and written out as code throughout the book. You’ll also become familiar with various aspects of server-side development such as scalability, database options, and information flow for microservices that are unwrapped in the process. As you advance, you’ll get to grips with microservices testing and see how it is different from testing a monolith application. Along the way, you’ll explore tools such as Docker, Postman, and Amazon Web Services. By the end of the book, you’ll be able to build a ready-to-deploy application that can be used as a base for future applications.

Who is this book for?

The book is for iOS, iPadOS, and macOS developers and Swift programmers who want to understand how Swift can be used for building microservices. The book assumes familiarity with Swift programming and the fundamentals of the web, including how APIs work.

What you will learn

  • Grasp server-side Swift development concepts using practical examples
  • Understand the microservices approach and why Swift is a great choice for building microservices
  • Design and structure mobile and web applications using microservices architecture
  • Discover the available database options and understand which one to choose
  • Scale and monitor your microservices
  • Use Postman to automate testing for your microservices API

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Mar 02, 2020
Length: 392 pages
Edition : 1st
Language : English
ISBN-13 : 9781789530889
Vendor :
Apple
Languages :
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Mar 02, 2020
Length: 392 pages
Edition : 1st
Language : English
ISBN-13 : 9781789530889
Vendor :
Apple
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just NZ$7 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just NZ$7 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total NZ$ 154.97
Hands-On Swift 5 Microservices Development
NZ$48.99
Learn SwiftUI
NZ$48.99
Mastering Swift 5.3
NZ$56.99
Total NZ$ 154.97 Stars icon

Table of Contents

18 Chapters
Introduction to Microservices Chevron down icon Chevron up icon
Understanding Server-Side Swift Chevron down icon Chevron up icon
Getting Started with the Vapor Framework Chevron down icon Chevron up icon
Planning an Online Store Application Chevron down icon Chevron up icon
Creating Your First Microservice Chevron down icon Chevron up icon
Application Structure and Database Design Chevron down icon Chevron up icon
Writing the User Service Chevron down icon Chevron up icon
Testing Microservices Chevron down icon Chevron up icon
Product Management Service Chevron down icon Chevron up icon
Understanding Microservices Communication Chevron down icon Chevron up icon
Order Management Service Chevron down icon Chevron up icon
Best Practices Chevron down icon Chevron up icon
Hosting Microservices Chevron down icon Chevron up icon
Docker and the Cloud Chevron down icon Chevron up icon
Deploying Microservices in the Cloud Chevron down icon Chevron up icon
Scaling and Monitoring Microservices Chevron down icon Chevron up icon
Assessment Answers Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
(6 Ratings)
5 star 33.3%
4 star 0%
3 star 16.7%
2 star 33.3%
1 star 16.7%
Filter icon Filter
Top Reviews

Filter reviews by




Carmi Weinzweig May 25, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Starting with a user service (including sending mail confirmations), the author develops a full micro services architecture built with the latest version of Vapor (Vapor 4). I started with only a little Swift experience and as I have progressed through the book, I have developed a good understanding of both Vapor 4 and why/how to use a microservice architecture. The author has been great about updating the code as Vapor 4 moved from Beta to release.The book develops the back end for an online store and covers everything from handing multi-service user authentication to deploying with Docker/Kubernetes on AWS, Google Cloud Platform (GCP) (although I have not really looked at that section), and Digital Ocean (a great less expensive option for certain kinds of deployments).I saw another review (part of what got me to write this one) and I am not sure what problems he had. It might be he was not working with the right version of Vapor (it was in its final release cycle and updating frequently). I purchased the book on the Apple Book Store (I had an iTunes gift card I wanted to use), and one of the great features of the digital versions is that they get updated as things change (very valuable for technical books).Finally, I recommend that anyone reading this book, join the Vapor community on Discord. The authors of most of the Vapor/Server-Side Swift books are there, and have happily helped as I have been developing my personal project (a web comic and media site), even with other authors’ books.The book starts with great explanation of why one would want to use microservices and what the downsides are as well. The author then explains how one can move from a monolithic app to a microservices architecture, by moving components one at a time, and even using it for add new functionality.Next the author discusses server-side Swift explaining some of its benefits and why Vapor was used as the book’s platform.The book then gives an introduction to Vapor covering its architecture and ORM (Fluent). While it is not a full Vapor 4 tutorial, it is more than enough to get started.With that background, the author begins to layout the architecture of the application being built. Starting with a user service that includes basic address management, the author explains how to test and debug microservices.The product management service is next, and now with two services, the book details how to communicate among one’s microservices. It talks about best practices and pitfalls to avoid. After adding the order service, it is time to cover deployment.Starting with options for hosting and a discussion of the current state of Swift on Linux, the book works its way through what is needed to deploy and scale a Swift-based server-side application. Again, as with its material on Vapor, this is not a complete Docker, Kubernetes, AWS, GCP or Digital Ocean tutorial, but more than enough to get started and understand what else one needs to learn.In addition to the book itself, the author has made available all the source code for the projects being built making it a great starting point for someone working on a real system. Overall, I think it is a great starting point for someone interested in exploring both server-side Swift and microservices.
Amazon Verified review Amazon
Pete D Jun 15, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Being a novice at writing swift Vapor backends, I have a bit of familiarity with how they work. In addition, I’ve been exposed to microservices quite a bit but have never written them myself. Given my knowledge, I found this book to be the perfect intersection of the two. The author does an impeccable job teaching users the concepts of microservices via a swift vapor implementation. In addition, the author does well to describe asynchronous concepts, jobs processing, and other backend type work that goes beyond your typical REST API framework. You’d be hard pressed to find a better swift / vapor microservices backend book.Granted, there are some minor mistakes in this book, however they are simple and reading over it it’s easy to fix when you follow along with the code. In addition, the content is subject to change as it was written while Vapor 4 is in beta. The author says he will update this book when Vapor 4 makes a full public release.How do I know this? Well the author is very involved in the Vapor community, and actively contributes to the chat, and answers anyone’s questions that they have on the book. I personally had some issues when implementing some code, and while it was not due to his fault, but rather a beta issue with Vapor 4, he promptly assisted me in resolving the issue.I’d not like to emphasis small mishaps with this book, because they don’t have much relevance in my opinion. When you purchase this book, you’re not only getting quality content, but you’re getting personal help from the author, and future updates. Now for the price of this book, it’s well worth more than the cost. Along with being in the community, you’ll feel right at home, and the author is sure to make you feel that way too.I’d highly recommend this book, not just for the Vapor 4 side of things, but showing you how to create microservices that are interactive. That in itself is timeless information that will be useful for plenty of years to come.
Amazon Verified review Amazon
Vital Zanko Dec 26, 2023
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
This is a quite good book uncovering Vapor subject especially to someones who are unfamiliar with Swift back end frameworks. Yet that only means its text is mostly useful to get in.But code examples are not well-organized: the author asks to "copy-paste" code from repos of previous chapters when a happy reader is interested in out-of-box repository for the chapter (a reader can be not interested much in the previous chapters and either he should not find out proper steps in them; it makes more sense to provide out-of-box repository that a reader can start easily and may alter working code on his own whether he wishes).
Amazon Verified review Amazon
E. Leonard Jun 19, 2021
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
I returned the book for the following reasons:The source code in the book bears little resemblance to the related Git repository.Even the supplied source code could not be run despite the .env environment being set as required. I could have muddled through and patched it together with a lot of research and trial and error but that defeats the point of a 'how to' book and means you're flying solo, in which case you might not have bothered with the book. I would like o see the book brought up to date and better (no assumptions made) directions in the text. The step1, step 2, step 3 type instructions in the book make a lot of assumed knowledge leaps early on and it requires reading a few times to clear the mist.I so wanted it to be great and give it a 5-stars as there's not enough server-side Swift in the world, unfortunately, this needs a bit of work to get it to a higher rating.
Amazon Verified review Amazon
Wunschzettel Kinder Oct 29, 2022
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
This book would need quite a bit of editing in many directions, some examples:- Explanations/didactics often could be better "The difference to EventLoopFuture is that a Future is what is the result of a Promise" (Page 60)- Missing checks on examples, Chapter 2 compares source for Swift 4.2 and Swift 5 and points out the difference. There is no difference in the book, the lines are identical. (Page 49)- Dependencies between chapters "The following components need to be installed: [...] Docker [...]" (Chapter 5), "Installing Git and Docker" (Chapter 6)- Teaches bad behavior: creating Public / Private Keys via web service - it does mention you should create public/private keys using command line tools, but neither why not how to (book refers to the website) (Page 125/126)In my opinion the book gets a bit better at around chapter 6 / 7, but still could be vastly improved.As of today, I would suggest to buy "Server-Side Swift with Vapor" instead.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.