Reader small image

You're reading from  Swift 3 New Features

Product typeBook
Published inOct 2016
Reading LevelIntermediate
PublisherPackt
ISBN-139781786469632
Edition1st Edition
Languages
Right arrow
Author (1)
Keith Elliott
Keith Elliott
author image
Keith Elliott

Keith Elliott is a multitalented professional with unique business and technology experience spanning telecommunications, real estate investment banking, and capital markets. His work is driven simply by problems that need solutions, whether the problem is as simple as his wifes request for a custom to-do list or as complex as interest rate derivatives and foreign exchange hedging. He graduated with an MBA from Columbia Business School with an emphasis in entrepreneurship and an undergraduate degree from Georgia Institute of Technology with a bachelor's in computer engineering. Keith's own company, GittieLabs LLC, works with startups to provide technology solutions. His vision is to equip students with the real-life experience necessary to succeed in startup and corporate life. You can find his blog on the GittieLabs LLC website, www.gittie.com. On nights and weekends, Keith can be found spending time with his family, riding motorcycles with his lovely wife, watching football, and rewatching countless hours of WWDC videos.
Read more about Keith Elliott

Right arrow

Preface

With the release of Swift 3, Apple is seeking to increase adoption of Swift. The mission of this book is to very quickly get new and seasoned developers up to speed and productive with Swift 3. We will explore the major features introduced to Foundation and the Standard Library. We will also provide commentary on how to convert existing Swift 2.2 projects to Swift 3 and examine Swift’s support for running and developing on Linux.

Objectives and achievements 

My objective is to introduce you to new concepts available with the release of Swift 3. Our journey together will hopefully lead you to a greater understanding in the following areas:

  • Understanding how the Grand Renaming will make your code easier to write and understand by other developers

  • Getting comfortable with the tools available to write Swift applications on a Mac or on Linux

  • Converting your Swift 2.2 projects to Swift 3

  • Making you aware of the syntax changes new to Swift 3

What this book covers

Chapter 1, What Were They Thinking?, introduces you to Swift 3. Swift is an important language for Apple and its adoption rate has been amazing so far. We will cover the process for how changes to the language are selected and how the community can contribute. In addition, we will cover Swift.org and Apple’s Github page as the repositories for everything that is happening in Swift.

Chapter 2, Discovering New Territories - Linux at Last!, discusses that, while Mac development was your only supported option up until recently, Swift 3 supports developing and running Swift applications on a Linux machine. Our goal is get your development environment setup on both a Mac and a Linux machine by the end of this chapter. We will write our first Linux application together.

Chapter 3, Migrating to Swift 3 to Be More Swifty, will show how to use the Swift Migrator to upgrade our Swift 2.2 projects.  We will use a sample project to walk through using the migrator and outline some useful strategies when migrating a Swift project.

Chapter 4, Changes to Swift's Core Will Have Asking for More, will quickly highlight the philosophies for writing good Swift APIs. Afterwards, we will spend the remaining chapter on language improvements for referencing and using Objective-C features in Swift 3 and importing code from Objective-C and C to Swift 3.

Chapter 5, Function and Operator Changes – New Ways to Get Things Done, will examine what's changed in function declaration and usage and how those changes translate into better Swift code. We will also explain operator changes and highlight several that have been removed from the language.

Chapter 6, Extra, Extra Collection and Closure Changes That Rock!, here we are focusing on collection and closure changes in Swift 3. There are several nice additions that will make working with collections even more fun. We will also explore some of the confusing side effects of creating closures in Swift 2.2 and how those have been fixed in Swift 3.

Chapter 7, Hold onto Your Chair, Advanced Type Changes are Here!, We are going to cover a few improvements to the language that you might not use on a regular basis. This chapter focuses on UnsafePointer types, typealiases, and floating point operations.

Chapter 8, Oh Goodness! Look What is New in the Foundation Framework, we will discuss the new Measurements and Units API. We will use several examples to hammer in the concepts so that you will leave this chapter better prepared to handle your measurement challenges in the future.

Chapter 9, Improving Your Code with Xcode Server and LLDB Debugging, we will cover Xcode Server’s capabilities as a continuous integration server and how automated testing can be included to improve your testing workflow. In the second half, we will describe how to use LLDB for debugging your code on Linux.

Chapter 10, Exploring Swift on the Server, shows that Swift running on Linux is a big deal, especially with Linux’s popularity for hosting and running servers. Swift 3 opens the possibilities for developers to create server-side applications using the same Swift that they use to create applications on iOS, macOS, tvOS, and watchOS. By the end of this chapter, you will have a running server written completely in Swift on a Linux box.

What you need for this book

This book will guide you through the installation of all the tools that you need to follow the examples. You will need to install Webstorm version 10 to effectively run the code samples present in this book.

Who this book is for

To develop in Swift 3 on a Mac, you will need Xcode 8 and macOS Sierra 10.12.  If you would like to take advantage of Swift on Linux, you need access to a Linux machine or virtual machine capable of running Ubuntu 14.04. 

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Download the toolchain file"

A block of code is set as follows:

h5> oneMillion = "one million"
error: repl.swift:11:12: error: cannot assign to value: 'oneMillion' is a
'let' constant
oneMillion = "one million"
~~~~~~~~~~~^
repl.swift:2:1: note: change 'let' to 'var' to make it mutable`
let oneMillion = 1\_000\_000`
^~~~
var

Any command-line input or output is written as follows:

$ swift

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Next, you select the Toolchain you want to develop against, which will only change the Xcode settings"

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail feedback@packtpub.com, and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Swift-3-New-Features. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at copyright@packtpub.com with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at questions@packtpub.com, and we will do our best to address the problem.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Swift 3 New Features
Published in: Oct 2016Publisher: PacktISBN-13: 9781786469632
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Keith Elliott

Keith Elliott is a multitalented professional with unique business and technology experience spanning telecommunications, real estate investment banking, and capital markets. His work is driven simply by problems that need solutions, whether the problem is as simple as his wifes request for a custom to-do list or as complex as interest rate derivatives and foreign exchange hedging. He graduated with an MBA from Columbia Business School with an emphasis in entrepreneurship and an undergraduate degree from Georgia Institute of Technology with a bachelor's in computer engineering. Keith's own company, GittieLabs LLC, works with startups to provide technology solutions. His vision is to equip students with the real-life experience necessary to succeed in startup and corporate life. You can find his blog on the GittieLabs LLC website, www.gittie.com. On nights and weekends, Keith can be found spending time with his family, riding motorcycles with his lovely wife, watching football, and rewatching countless hours of WWDC videos.
Read more about Keith Elliott