Learn Swift by Building Applications

Book description

Start building your very own mobile apps with this comprehensive introduction to Swift and object-oriented programming

About This Book
  • A complete beginner's guide to Swift programming language
  • Understand core Swift programming concepts and techniques for creating popular iOS apps
  • Start your journey toward building mobile app development with this practical guide
Who This Book Is For

This book is for beginners who are new to Swift or may have some preliminary knowledge of Objective-C. If you are interested in learning and mastering Swift in Apple's ecosystem, namely mobile development, then this book is for you.

What You Will Learn
  • Become a pro at iOS development by creating simple-to-complex iOS mobile applications
  • Master Playgrounds, a unique and intuitive approach to teaching Xcode
  • Tackle the basics, including variables, if clauses, functions, loops and structures, classes, and inheritance
  • Model real-world objects in Swift and have an in-depth understanding of the data structures used, along with OOP concepts and protocols
  • Use CocoaPods, an open source Swift package manager to ease your everyday developer requirements
  • Develop a wide range of apps, from a simple weather app to an Instagram-like social app
  • Get ahead in the industry by learning how to use third-party libraries efficiently in your apps
In Detail

Swift Language is now more powerful than ever; it has introduced new ways to solve old problems and has gone on to become one of the fastest growing popular languages. It is now a de-facto choice for iOS developers and it powers most of the newly released and popular apps. This practical guide will help you to begin your journey with Swift programming through learning how to build iOS apps.

You will learn all about basic variables, if clauses, functions, loops, and other core concepts; then structures, classes, and inheritance will be discussed. Next, you'll dive into developing a weather app that consumes data from the internet and presents information to the user. The final project is more complex, involving creating an Instagram like app that integrates different external libraries. The app also uses CocoaPods as its package dependency manager, to give you a cutting-edge tool to add to your skillset. By the end of the book, you will have learned how to model real-world apps in Swift.

Style and approach

This book has a very practical and hands-on approach towards teaching the user the new and advanced features of Swift.

Publisher resources

Download Example Code

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Learn Swift by Building Applications
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Swift Basics – Variables and Functions
    1. Variables
      1. Optional types
    2. Enumeration types
    3. Basic flow statements
      1. The if statements – how to control the code flow
      2. Loops
        1. The while loops
      3. The switch statement
    4. Functions
      1. What is a tuple?
      2. What is the guard statement?
      3. How to tackle huge problems – bottom-up versus top-down
    5. Summary
  7. Getting Familiar with Xcode and Playgrounds
    1. Installing Xcode
    2. Exploring Xcode
      1. What do we see on the screen?
        1. Toolbar
        2. Menu
        3. The Navigator panel (located to the left)
        4. The Debug panel (located at the bottom)
        5. The Utilities panel (located to the right)
        6. Xcode preferences window
    3. Playground
      1. What is a playground?
      2. Let's add some code
      3. How to add auxiliary code to a playground
        1. How to add resource to a playground
      4. Converting a playground to a workspace
      5. Markup in playgrounds
        1. Different items in the markup language
        2. Basic markup items
    4. Summary
  8. Creating a Minimal Mobile App
    1. Your first iOS application
      1. Project structure
        1. AppDelegate
        2. Application states
        3. ViewController
      2. Git
    2. Summary
  9. Structures, Classes, and Inheritance
    1. Structures and classes
      1. Extensions
      2. The deinit method
      3. Type properties and functions
      4. Adding custom data types to a playground
    2. Inheritance
      1. Base class
        1. Class properties
      2. Model-View-Controller (MVC)
    3. Summary
  10. Adding Interactivity to Your First App
    1. Storyboards
      1. Visual components
      2. Adding items to the storyboard
      3. Linking the UI with the code
      4. General discussion
    2. Summary
  11. How to Use Data Structures, OOP, and Protocols
    1. Primary collection types
      1. Generics
      2. Array
      3. Set
      4. Dictionary
      5. How to choose the best collection type
    2. List of items in a playground
      1. UICollectionView
        1. UICollectionViewCell
        2. Reusing cells
        3. Layouts
    3. Table view in iOS app
      1. Model list of cities
        1. Displaying all cities
        2. Adding search
    4. Protocols
      1. Protocols and inheritance
    5. Summary
  12. Developing a Simple Weather App
    1. Defining the app screens
      1. The home screen
      2. Favorite locations
        1. Constraints
      3. Picking a location
    2. Model
      1. Locations
      2. Controllers and segues
        1. The first segue
        2. How to pass data
        3. Passing information in the reverse direction
        4. Defining a custom segue
      3. Further improvements
    3. Summary
  13. Introducing CocoaPods and Project Dependencies
    1. Software – the modern way
      1. Ruby and CocoaPods
        1. How to use it
      2. CocoaPods useful commands
    2. Carthage
    3. Swift Package Manager 
      1. Useful commands
    4. Popular third-party libraries
      1. Alamofire
      2. Texture
      3. RxSwift
    5. Summary
  14. Improving a Version of a Weather App
    1. Weather forecast API
      1. What's an API?
      2. List of requests
      3. Creating new models
    2. Pure network requests
      1. Alamofire implementation
      2. Improvements using third-party libraries
      3. Better error handling
      4. About the screen
    3. Summary
  15. Building an Instagram-Like App
    1. Tabbed app project
    2. Firebase
      1. Login
      2. The different screens
      3. Custom buttons on the tab bar
      4. Creating a post
      5. Models
      6. Firebase
      7. Filters
    3. Summary
  16. Instagram-Like App Continued
    1. Home screen
    2. Profile screen
    3. Search screen
    4. Favorites screen
    5. Polishing the home screen
    6. Summary 
  17. Contributing to an Open Source Project
    1. Your account at GitHub
    2. Forking a repository
    3. Let's contribute
    4. Pull request
    5. Summary
  18. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Learn Swift by Building Applications
  • Author(s): Emil Atanasov
  • Release date: May 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781786463920