Book Image

Swift Game Development - Third Edition

By : Siddharth Shekar, Stephen Haney
Book Image

Swift Game Development - Third Edition

By: Siddharth Shekar, Stephen Haney

Overview of this book

Swift is the perfect choice for game development. Developers are intrigued by Swift and want to make use of new features to develop their best games yet. Packed with best practices and easy-to-use examples, this book leads you step by step through the development of your first Swift game. The book starts by introducing Swift's best features – including its new ones for game development. Using SpriteKit, you will learn how to animate sprites and textures. Along the way, you will master physics, animations, and collision effects and how to build the UI aspects of a game. You will then work on creating a 3D game using the SceneKit framework. Further, we will look at how to add monetization and integrate Game Center. With iOS 12, we see the introduction of ARKit 2.0. This new version allows us to integrate shared experiences such as multiplayer augmented reality and persistent AR that is tied to a specific location so that the same information can be replicated on all connected devices. In the next section, we will dive into creating Augmented Reality games using SpriteKit and SceneKit. Then, finally, we will see how to create a Multipeer AR project to connect two devices, and send and receive data back and forth between those devices in real time. By the end of this book, you will be able to create your own iOS games using Swift and publish them on the iOS App Store.
Table of Contents (22 chapters)
Swift Game Development Third Edition
Contributors
Preface
Other Books You May Enjoy
Index

New in Swift 4.2


This year, we have the release of Swift version 4.2 with Xcode 10. Unlike previous years where we saw a full release of a Swift version, like Swift 3.0 and Swift 4.0, this year, we see the release of Version 4.2. Swift 5.0 has been moved to the sometime early next year in 2019.

Xcode 10 will be the last version to support Swift 3.0 Compatibility Mode. So, if your app uses Xcode version 3, the code needs to be migrated to at least 4.0 by next year.

Further refinements have also been introduced by Apple in Swift 4.2:

  • Speedup Debug Builds: Code builds at least twice as fast compared to previous versions of Xcode. This will depend on the nature of the product and how much Swift code it uses. Compilation is optimized to reduce redundant work.

  • Runtime Optimization: Swift 4.2 introduces a couple of under the hood runtime optimizations. For example, in 4.2, all intermediate retains and releases of objects are removed and the object only gets released once at the end, improving the runtime of the code. This also enables automatic code size optimization.

  • Small String: String is now 16 bites as compared to 24 in the previous version. It also enables a small string memory optimization. If the string is within 15 bites, then the string is represented in the string type without requiring separate allocation to represent the string.

  • Reduction in Code Size: There is a new optimization level which reduces the machine level code size generated from the compilation of the swift code. This optimization enables 10% to 30% reduction in code size with a 5% hit in runtime performance.

Swift has already made tremendous steps forward as a powerful, young language. Now, Apple is working on polishing Swift into a mature, production-ready tool. The overall developer experience improves with Swift 4.2.

With Swift 4.2, we are moving toward binary compatibility and with Swift 5.0 releasing in early 2019, this transition will be complete. With this, Apple will be able to ship the Swift runtime along with the OS itself and doesn't need to be included in the App bundle as it is currently. This will improve startup time and memory usage of the application itself. More information about binary compatibility/ abi-stability is available at swift.org/abi-stability.

Note

For a detailed look at what's new in Swift, I highly recommend watching the WWDC 2018 video:

https://developer.apple.com/videos/play/wwdc2018/401/.