Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
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

₹1,965.99 ₹800.00
Book Mar 2020 392 pages 1st Edition
eBook
₹1,965.99 ₹800.00
Print
₹2,457.99
Subscription
₹800 Monthly
eBook
₹1,965.99 ₹800.00
Print
₹2,457.99
Subscription
₹800 Monthly

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Mar 2, 2020
Length 392 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781789530889
Vendor :
Apple
Category :
Concepts :
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...

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...

Swift performance

Swift is competing with a good number of frameworks and languages. Some might argue that performance is only one out of many factors that should be considered when choosing a technology. While that is undoubtedly true, think of this: you want to build a project in a way where technology will not hold you back much. Facebook, as well as Uber, has spent years rebuilding and reworking their infrastructure. No matter what technology you choose, you will most likely refactor your application as well. However, having selected a stack that allows you to do so gracefully is crucial.

You could be looking at some raw benchmarks in this section, but I think it makes more sense to analyze with a bit more depth what performance holistically looks like for a project. When comparing Swift to its competition, you want to stay as clean and objective as possible; the following...

Swift on the server

What does it look like to run a Swift application on a server? When Swift was released as open source, it was released for Linux right away as well. Specifically, Swift favors the Linux flavor, Ubuntu. Hosting a Swift application is very different from traditional web hosting. If you get a web hosting package from companies such as GoDaddy, you will not see them say "Runs Swift 5". Most mainstream web hosters only offer scripting languages. The reasoning is simple:

  • Most applications use scripting languages.
  • Scripting applications can share the same server.

Swift, on the other hand, as a native language, is the actual web server itself. What that means is that your Swift application is directly responding to incoming requests. Let's look at the following aspects of server-side Swift:

  • A self-contained server
  • Linux/Ubuntu
  • SwiftNIO
  • Docker

Let...

Features of Swift 5

You already have an understanding of how Swift works. In this section, we are looking at some of the newest features that Apple has released at the time of writing this book. There are a lot of bug fixes and changes in every Swift update, but the following features are particularly noteworthy for us in Swift version 5:

  • ABI stability
  • Raw strings and UTF8 strings
  • Result type
  • Future enum cases
  • Flattening nested optionals

There are a couple more interesting new features of Swift 5. However, this section only contains the ones that will be most relevant for server development. Take a look.

ABI stability

One particularly interesting new feature is that Swift is now ABI-compatible with version 5.0 and later...

Summary

In this chapter, you looked at the history of Swift and why it stands out from other languages. You then learned why Swift has been leaning toward server development from the beginning. After looking at Swift's performance compared to other languages and frameworks, you learned about Swift on the server and what is currently supported. Docker and SwiftNIO should be terms you can explain by now. Finally, you explored the features of Swift 5 and have seen examples of what the changes could look like in practice.

Go through the Questions section to validate your understanding of Swift on the server.

In the next chapter, you are going to explore the Vapor framework and you will be set up to create web applications with Vapor and Swift.

Questions

To see whether you understood the gist of server-side Swift, try answering the following questions:

  1. Why is Swift being a native language helpful?
  2. What is the preferred OS for server-side Swift applications at the moment?
  3. What is SwiftNIO?
  4. How does Docker help?
  5. Name three of the added benefits of Swift 5.
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.

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

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


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

Table of Contents

19 Chapters
Preface Chevron down icon Chevron up icon
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

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

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.