Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Swift 3 New Features
Swift 3 New Features

Swift 3 New Features: Get up to date with what`s new in Swift 3

By Keith Elliott
R$147.99 R$80.00
Book Oct 2016 142 pages 1st Edition
eBook
R$147.99 R$80.00
Print
R$183.99
Subscription
Free Trial
eBook
R$147.99 R$80.00
Print
R$183.99
Subscription
Free Trial

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 : Oct 6, 2016
Length 142 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781786469632
Vendor :
Apple
Category :
Table of content icon View table of contents Preview book icon Preview Book

Swift 3 New Features

Chapter 1. What Were They Thinking?

Apple's release of Swift was a smashing hit from the very beginning. The language generated a lot of hype and it delivered. Of course, with the introduction of any new programming language, problems and issues will come along for the ride. Apple has carefully cultivated the young language, and has been steadily improving its base and introducing new features, support, and compatibility with its long mainstay incumbent, Objective-C. So, why would Apple open-source the language? What is Apple's objective and what does that tell us about the forthcoming release of Swift 3?

The focus of this chapter is to discuss Apple's goals for Swift 3, to show you where you can find the source of official information about new and current development in the language, and to explain how the community of developers will shape the fate of Swift as a language.

Apple's goals for Swift 3


During the What's New In Swift lecture from Apple's World Wide Developer Conference (WWDC) 2016, Apple engineers outlined several goals for the upcoming release of Swift 3:

  • Develop an open community

  • Portability to new platforms

  • Get the fundamentals right

  • Optimize for awesomeness

Note

If you missed the conference, you can watch a replay of the talk on Apple's developer portal. Here's the link for What's New In Swift: https://developer.apple.com/videos/play/wwdc2016/42.

I want to briefly touch on a couple of themes here as it will provide a base for the material you will find in the remaining chapters:

  • Apple believes that for Swift to grow in adoption it needs a strong community. The path to rapid Swift adoption is to include the voices of the community in its development.

  • Swift is a general-purpose language that could and should run on any platform. Imagine running Swift on Linux or on the Internet of Things (IoT) you create or need to control. Apple believes that the Swift language is so capable that they removed the barriers that tied Swift to running on a Mac, opening endless possibilities for platform portability. Apple wants the community to find ways to get Swift to run on other platforms. Today, the Swift team is supporting a port to Linux. Tomorrow, the Swift team could have official support for a wide range of platforms.

  • In order to make the first two themes possible, the Swift team needs to get things right from the beginning with Swift 3. Unfortunately, this means that the new changes in Swift 3 do not work well with previous releases of Swift. The Swift 3 release will fix and remove things that were awkward in Swift 2 (and its predecessors). Swift 3 also re-imagines how it interacts with Cocoa and Objective-C to make the APIs that bridge them feel more Swifty.

Swift is a really big deal to Apple and expectations from the language are high. Apple has laid out its roadmap for how it expects to reach its goals. In fact, you can stay current with all things Swift by subscribing to one of the mailing lists found here https://swift.org/community/#mailing-lists. The main method for communicating with the Swift community is via mailing lists. You can find mailing lists that cater to general information as well as lists for day-to-day updates on the language. The Swift mailing lists can be a valuable tool that you should not overlook.

In the next section, we will talk about what the open source community means for you as a Swift developer.

Open source Swift


On December 3 2015, Apple open-sourced Swift (including the language, supporting libraries, debugger, and package manager) under the Apache 2.0 license and launched the https://Swift.org/ website on the same day. https://Swift.org/ is the official site to find resources on the various projects that make up Swift. It's your main source to read announcements on all of the development work on the language, from proposals of new features, to links to development branches of Swift code that you can download and test.

https://Swift.org/ is a website that you will want to bookmark for future reference. The entire Swift codebase is hosted on GitHub and is available for anyone to access. Take a second to think about that. Anyone can download Swift, play around with a binary, build a project, or look under the hood to see how things actually work. For a company of Apple's size and reputation, releasing Swift, the language that they are betting on to power all of their applications, to the community is amazing and should not be taken lightly. This is huge!

Naturally, Apple didn't just hand the language over and walk away. Instead, Apple set up an internal team to shepherd the development process and to be responsible for the day-to-day project management. The open sourced version of the Swift language is comprised of a group of projects each hosted as a separate repository on GitHub. Today, you can find links to six active projects:

  • Swift compiler: Command line tool

  • Standard library: Distributed as part of the core language

  • Core libraries: Provide a higher level functionality

  • LLDB debugger: Includes the Swift REPL

  • Swift Package manager: Building projects and distributing them

Each project has a dedicated section on https://Swift.org/ that explains the project goals and links on how to use both Swift and contribute as a community member. I encourage you to review https://Swift.org/ to get a better handle on all things Swift from Apple's perspective. Before we end our section on where to find resources on Swift, I do want to briefly discuss what it means to be a community contributor.

The community structure has been well thought out and it's designed to provide strong leadership from members in the community. This structure will guide the on-going development of the language and will hopefully ensure that as the community expands, many new community contributors will have a voice that is heard and respected. See below for the roles that make up members of the community:

  • Project Lead: Apple is the project lead and will select others from the community to serve in various technical lead positions

  • Core Team: This small team of engineers is responsible for strategic direction

  • Code Owner: This title goes to anyone responsible for a specific area of a Swift project codebase

  • Committer: This role is given to anyone with commit access to a Swift repository

  • Contributor: This role is reserved for anyone who contributes to a patch or helps with a code review

You can read more about the individual roles in the community on https://Swift.org/ under the community section. The Swift community is growing and, not unexpectedly, many developers are curious about  how to contribute. With that in mind, let's explore how things get done.

Contributing to Swift


There are a few ways that you can help make the community and Swift better. Surprisingly, it's not just by cranking out code. The community needs support with answering questions on the mailing lists. Your answers could range from helping a newbie get a better grasp on a new concept to, going to the opposite extreme, helping a seasoned developer work through a subtle bug. Either way, contributing your knowledge could be valuable to others and would be very much appreciated!

The next option for contributing to the Swift project is by either reporting or triaging bugs. The Swift team uses Jira for defect tracking and you can submit bugs on the project's Jira instance located at https://bugs.swift.org.

The final option you have as a developer is to contribute code. There is a formal process for committing code that we will briefly cover. The Swift project prefers small incremental changes to large commits or long-term disconnected feature branches. The Swift team also encourages, but does not enforce, commit messages that describe in detail what your committed code changes include. Code quality is extremely important and is emphasized through mandatory code reviews and pull requests to ensure at least another set of eyes has reviewed all code changes. Think of it this way; your changes will eventually make it into a production environment and have the potential to affect millions of developers that use the Swift language. Do you really want to take of chance introducing a defect that might affect millions of developers?

Swift evolution process


While Apple and the Swift team each have tons of great ideas on where Swift can go, it's important to remember that they aren't the only ones with ideas. In fact, the Swift team fully realizes this, and in response has created a process for you to submit your big or small ideas to help shape the Swift language.

The Swift evolution process encompasses all things related to taking a raw idea from inception through discussion and dialog and hopefully ending at an accepted proposal that developers can implement for production release. The goal of the process is to have active engagement within the community in order to steer the direction of the language while remaining true to the vision of Swift. In practice, that might translate into adding new features that make the language easier to use or removing features that no longer fit the vision of Swift. You can participate by proposing a new idea, or discussing and reviewing the proposals of other community members.

Swift evolution proposal steps

Here are the steps required to get a new idea moved into an accepted proposal:

  1. Check for similar proposals: It's important to do your homework and make sure that your idea hasn't already been proposed and/or rejected. Spend time reviewing proposals and their states. You can check the Commonly Rejected Proposals list for this task.

  2. Tell others about your idea: Most of the discussions around new ideas take place on the swift-evolution mailing list. This is where you should create a draft of your idea, along with the problem it addresses and some context on a solution.

  3. Create your proposal: Using the proposal template found here https://github.com/apple/swift-evolution/blob/master/0000-template.md, you elaborate on your idea and continue to socialize it on the evolution mailing list.

  4. Request a review: When you believe your proposal is ready for a formal review by the core team, you submit a pull request to the swift-evolution repository https://github.com/apple/swift-evolution. When your pull request is accepted, your proposal will be given a proposal number and assigned a core team member to facilitate the review.

  5. Respond to feedback: It's your job to respond to questions and feedback on your proposal on the mailing list. This is especially important during the review period.

If all goes well, your proposal will navigate through the proposal states below during the review process and will be accepted.

  • Awaiting review: Until the proposal is assigned a date period for review, your proposal remains in this state.

  • Under review: Your proposal is undergoing public review on the swift-evolution mailing list.

  • Under revision: If you are given feedback during the under-review state, you are given an opportunity to address and modify your proposal.

  • Deferred: Decision postponed because it doesn't meet the criteria for the upcoming major Swift release. In this state, your proposal will be reconsidered when scoping for the next major Swift release.

  • Accepted: Accepted and new work can begin or is actively being done to implement your accepted proposal. An announcement will also go out to let the community know of a new accepted proposal for the upcoming release.

  • Rejected: Considered but rejected by the core team.

Here are some key things to remember about the review process. It doesn't start until a core team member (review manager) accepts your pull request for the proposal. Once accepted, the review manager will coordinate a review period with you and any other authors of the proposal to start a formal public review. The review period is a week long in most cases, but can be longer depending on the scope and complexity of changes outlined in the submitted proposal. Finally, the core team, not just the review manager, will make a decision on the proposal using the comments from the swift-evolution mailing list to help base their decision.

Overview of accepted proposals for Swift 3


Each major release of Swift will have high-level goals to which accepted features must adhere. For the Swift 3 release, the Swift team outlined that the primary goal of this release is to solidify and mature the Swift language and development experience.

In their own words, the Swift team went on to stated that While source code breaking changes to the language have been the norm for Swift 1 through 3, we would like the Swift 3.x (and Swift 4+) languages to be as source-compatible with Swift 3.0 as reasonably possible. However, this will still be best-effort: if there is a really good reason to make a breaking change beyond Swift 3, we will consider it and find the least invasive way to roll out that change (for example, by having a long deprecation cycle).

In order to achieve the release goal for Swift 3, each of the following are considered important in terms of getting the basics right for future releases:

  • API design guideline

  • Automatic application of naming guidelines to imported Objective-C APIs

  • Adoption of naming guidelines in key APIs

  • Swiftification of imported Objective-C APIs

  • Focusing and refining the language

  • Improvements to tooling quality

You can learn more about each of these areas on the Swift Evolution repository page as well as see the complete list of implemented proposals, accepted but not yet implemented proposals, and rejected or withdrawn proposals.

Summary


In this chapter we discussed Apple's goals for Swift 3 and the importance of the community's engagement and involvement to the language's development. I also showed you where to find the source of official information about new and current development on the language. Last, we learned how the community can contribute to the development process of Swift as a language. In Chapter 2, Discovering New Territories – Linux at Last! We go over developing Swift on Linux.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Get up to date with the latest changes to Swift 3
  • Make your life easier by knowing how to port your Swift code to the latest version
  • Learn how to write programs that work on most of the major platforms such as iOS and Linux

Description

Since Swift was introduced by Apple in WWDC 2015, it has gone on to become one of the most beloved languages to develop iOS applications with. In the new version, the Swift team aimed to take its adoption to the next level by making it available for new platforms and audiences. This book will very quickly get you up to speed and productive with Swift 3. You will begin by understanding the process of submitting new feature requests for future versions of Swift. Swift 3 allows you to develop and run your applications on a Linux machine. Using this feature, you will write your first Linux application using the debugger in Linux. Using Swift migrator, you will initiate a conversion from Swift 2.2 to Swift 3. Further on, you will learn how to interact with Cocoa libraries when importing Objective C to Swift. You will explore the function and operator changes new to Swift 3, followed by Collection and Closure changes. You will also see the changes in Swift 3 that allow you write tests easier with XCTest and debug your running code better with new formats as well. Finally, you will have a running server written completely in Swift on a Linux box. By the end of the book, you will know everything you need to know to dive into Swift 3 and build successful projects.

What you will learn

[*] Migrate a Swift 2.2 project to Swift 3 [*] Understand the workings of Swift Package Manager [*] Interact with Cocoa libraries when importing Objective C to Swift [*] Explore the function and operator changes new in Swift 3 [*] Work with the advanced type changes, attribute improvements, and floating point type improvements in Swift [*] Discover the changes in the Swift API and see how Objective-C can be manipulated in the current API [*] Implement the new features central to Swift Testing and understand the new debug features [*] Create server-side applications using Swift 3

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 : Oct 6, 2016
Length 142 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781786469632
Vendor :
Apple
Category :

Table of Contents

16 Chapters
Swift 3 New Features Chevron down icon Chevron up icon
Credits Chevron down icon Chevron up icon
About the Author Chevron down icon Chevron up icon
About the Reviewer Chevron down icon Chevron up icon
www.PacktPub.com Chevron down icon Chevron up icon
Preface Chevron down icon Chevron up icon
What Were They Thinking? Chevron down icon Chevron up icon
Discovering New Territories – Linux at Last! Chevron down icon Chevron up icon
Migrating to Swift 3 to Be More Swifty Chevron down icon Chevron up icon
Changes to Swifts Core Will Have You Asking for More Chevron down icon Chevron up icon
Function and Operator Changes – New Ways to Get Things Done Chevron down icon Chevron up icon
Extra, Extra Collection and Closure Changes That Rock! Chevron down icon Chevron up icon
Hold onto Your Chair; Advanced Type Changes Are Here! Chevron down icon Chevron up icon
Oh Goodness! Look Whats New in the Foundation Framework Chevron down icon Chevron up icon
Improving Your Code with Xcode Server and LLDB Debugging Chevron down icon Chevron up icon
Exploring Swift on the Server 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.