100% found this document useful (2 votes)
16 views

Xcode 6 essentials create exciting native apps for your Apple devices with Xcode Varma - The ebook in PDF/DOCX format is ready for download now

The document promotes the book 'Xcode 6 Essentials' by Jayant Varma, which guides readers in creating native apps for Apple devices using Xcode. It includes links to download the book and other recommended resources on ebookultra.com. The book covers various aspects of Xcode, including installation, interface design, debugging, and app distribution.

Uploaded by

paveziyuls
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
16 views

Xcode 6 essentials create exciting native apps for your Apple devices with Xcode Varma - The ebook in PDF/DOCX format is ready for download now

The document promotes the book 'Xcode 6 Essentials' by Jayant Varma, which guides readers in creating native apps for Apple devices using Xcode. It includes links to download the book and other recommended resources on ebookultra.com. The book covers various aspects of Xcode, including installation, interface design, debugging, and app distribution.

Uploaded by

paveziyuls
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Download the full version and explore a variety of ebooks

or textbooks at https://ebookultra.com

Xcode 6 essentials create exciting native apps for


your Apple devices with Xcode Varma

_____ Follow the link below to get your download now _____

https://ebookultra.com/download/xcode-6-essentials-create-
exciting-native-apps-for-your-apple-devices-with-xcode-
varma/

Access ebookultra.com now to download high-quality


ebooks or textbooks
Here are some recommended products for you. Click the link to
download, or explore more at ebookultra.com

Creating iOS Apps With Xcode Learn How to Develop Your Own
App 1st Edition Aaron L. Bratcher

https://ebookultra.com/download/creating-ios-apps-with-xcode-learn-
how-to-develop-your-own-app-1st-edition-aaron-l-bratcher/

Big Book of Apple Hacks Tips Tools for Unlocking the Power
of Your Apple Devices 1st Edition Chris Seibold

https://ebookultra.com/download/big-book-of-apple-hacks-tips-tools-
for-unlocking-the-power-of-your-apple-devices-1st-edition-chris-
seibold/

iOS 9 Programming Fundamentals with Swift Swift Xcode and


Cocoa Basics 2nd Edition Matt Neuburg

https://ebookultra.com/download/ios-9-programming-fundamentals-with-
swift-swift-xcode-and-cocoa-basics-2nd-edition-matt-neuburg/

Professional Xcode 3 Wrox Programmer to Programmer 1st


Edition James Bucanek

https://ebookultra.com/download/professional-xcode-3-wrox-programmer-
to-programmer-1st-edition-james-bucanek/
Step into Xcode Mac OS X Development First Printing
Edition Fritz Anderson

https://ebookultra.com/download/step-into-xcode-mac-os-x-development-
first-printing-edition-fritz-anderson/

Pro iOS 5 Tools Xcode Instruments and Build Tools


Professional Apress 1st Edition Brandon Alexander

https://ebookultra.com/download/pro-ios-5-tools-xcode-instruments-and-
build-tools-professional-apress-1st-edition-brandon-alexander/

Apple Training Series Mac OS X Support Essentials 2nd


Edition Apple Training 2008 Kevin M. White

https://ebookultra.com/download/apple-training-series-mac-os-x-
support-essentials-2nd-edition-apple-training-2008-kevin-m-white/

Create Update Remake DIY Projects for You Your Family and
Your Home Canadian Living

https://ebookultra.com/download/create-update-remake-diy-projects-for-
you-your-family-and-your-home-canadian-living/

Create Great iPhone Photos Apps Tips Tricks and Effects


1st Edition Allan Hoffman

https://ebookultra.com/download/create-great-iphone-photos-apps-tips-
tricks-and-effects-1st-edition-allan-hoffman/
Xcode 6 essentials create exciting native apps for your
Apple devices with Xcode Varma Digital Instant
Download
Author(s): Varma, Jayant
ISBN(s): 9781784397791, 1784397792
Edition: Online-ausg
File Details: PDF, 3.11 MB
Year: 2015
Language: english
Xcode 6 Essentials

Create exciting native apps for your Apple devices


with Xcode

Jayant Varma

professional expertise distilled


P U B L I S H I N G

BIRMINGHAM - MUMBAI
Xcode 6 Essentials

Copyright © 2015 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

First published: January 2015

Production reference: 1220115

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham B3 2PB, UK.

ISBN 978-1-78439-443-1

www.packtpub.com
Credits

Author Project Coordinator


Jayant Varma Neha Thakur

Reviewers Proofreaders
Smart Cai Bridget Braund
Ben Dodson Stephen Copestake
Maria Gould
Acquisition Editor
Sonali Vernekar Indexer
Tejal Soni
Content Development Editor
Akashdeep Kundu Production Coordinator
Aparna Bhagat
Technical Editor
Tanvi Bhatt Cover Work
Aparna Bhagat
Copy Editors
Shivangi Chaturvedi
Gladson Monteiro
Jasmine Nadar
Merilyn Pereira
About the Author

Jayant Varma is a technophile with a career spanning over 2 decades and was
introduced to computing in the days of 8-bit computers and Z80 chips. While
managing the IT and telecom department at the BMW dealerships in India and
Oman, and Nissan in Qatar, he worked extensively on Windows, AS/400, and Unix.
His love for travelling inspired him to work and travel to several countries. He is
currently based in Australia.

His technological journey began as a Microsoft Technologies developer and has


diversified; his focus is now on Apple and mobile technologies. He has a masters
degree in Business Administration and IT from James Cook University, Australia. He
also lectured at James Cook University and co-ordinated the on-shore and off-shore
teaching for the Linux/Unix Administration subject. He worked closely with the
Australian Computer Society (ACS) and Apple University Consortium (AUC)
on workshops and projects.

He authored the book Learn Lua for iOS Game Development, Apress, and has also been
a technical reviewer on several titles.

As a founder, consultant, and developer at OZApps (www.oz-apps.com), he helps


organizations and individuals integrate technology into their business and strategies.
He also conducts trainings and workshops, and writes blogs to share his knowledge
with the community.
About the Reviewers

Smart Cai is a Chinese iOS developer with 3 years of experience in the field of
IT. Currently, he works as a software engineer at Beijing Effective Biz Info Tech Co,
LTD. He has also published an application on the App Store named, 今目标
(a business iOS App).

Ben Dodson is a freelance iOS developer in the UK. He has been working on
application development since the introduction of the App Store and has built
a number of high-ranking applications for clients, including Channel 4, Nectar,
ExpenseMagic, and NBC. Ben has also published a number of his own applications
including Highlights (featured as "iPad App of the Week" and "Best of 2011 Travel
Apps" by Apple) and WallaBee (voted "Best European Gaming Startup 2012" at
Nonick 012).

Ben spends the majority of his time working on WallaBee, the largest collecting game
on the App Store, of which he is the founder and the lead developer. He is currently
working on a number of exciting projects written in Swift and using the latest iOS 8
technologies. He is also working on a major game for the upcoming Apple Watch.

Find out more about him at www.bendodson.com.


www.PacktPub.com

Support files, eBooks, discount offers, and more


For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.
com and as a print book customer, you are entitled to a discount on the eBook copy.
Get in touch with us at service@packtpub.com for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign
up for a range of free newsletters and receive exclusive discounts and offers on Packt
books and eBooks.
TM

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser

Free access for Packt account holders


If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view 9 entirely free books. Simply use your login credentials for
immediate access.
Table of Contents
Preface 1
Chapter 1: Introduction to Xcode 7
Requirements and installing Xcode 7
Features of Xcode 10
What's new in Xcode 6? 10
Interactive coding using Playgrounds 11
Mac OS X storyboards 11
Live design and responsive UI 11
Visual debugging 11
Improved debugger 12
Summary 12
Chapter 2: Tour of Xcode 13
Starting Xcode 13
Creating a new project 14
Selecting the project type 14
Setting the project options 15
Setting the project properties 15
Xcode overview 15
The project section 17
The editor and assistant editor sections 18
Source code editors 18
The assistant editor 20
The utility/inspector section 20
The Apple development languages 23
Swift 23
Summary 24
Table of Contents

Chapter 3: Playgrounds 25
Introduction 25
Swift Playgrounds 26
The UI 26
Learning Swift 29
Console output printing 29
Working with variables 29
Variable types 30
Declaring variables 30
What are Int, Double, and Float variables 31
Adding different types 31
Booleans 32
Arrays and dictionaries 32
Tuples 37
Strings 37
Any and AnyObject 38
Control flows and code execution 39
The if statement 39
The if..else statement 39
The if..elseif..else statement 39
The ternary operator 40
For loops 40
The While loop 42
The switch condition 42
Functions 47
Return values 47
Parameters 48
Using closures 50
Objects 51
Classes 51
Enumerations 54
Extensions – extending the classes 55
Operator overloading 56
Summary 57
Chapter 4: Interface Builder 59
Introducing Interface Builder 60
Creating a basic interface 61
Elements on the view 62
Adaptive UI 64
Adding scenes 68
Navigating between View Controllers 69
Building a simple application 71
Adding items to Table View 71
Different elements for different orientations and dimensions 76
Adding the code 77

[ ii ]
Table of Contents

Autolayout 79
Subclassing 80
Quick help 82
Managing connections 83
Adding gesture recognizers 84
Segues and connections 86
Summary 87
Chapter 5: Custom Controls 89
An introduction to custom controls 89
The basics 89
Creating a class 90
Properties 91
Changing properties from the inspector 93
Enhancing custom controls 93
Adding some text 95
Frameworks 96
Creating a framework 96
Debugging custom controls 98
Summary 99
Chapter 6: Debugging 101
Breakpoints 102
Listing all the breakpoints 103
Navigating 103
The console 104
Understanding the debug information 105
Visualizing variables with the Quick Look functionality 107
Using images with quick view 109
Debugging the view hierarchy 110
Introducing debug gauges 112
Summary 113
Chapter 7: Building and Running 115
Simulator 115
Choosing the device 116
Preparing for distribution 116
Configuring the project settings 117
The Identity section 117
The Deployment Info section 118
Application icons and launch images 118
Linked frameworks and libraries 120

[ iii ]
Table of Contents

The Capabilities tab 120


The Info tab 120
The Build tabs 121
The Targets tab 121
Setting project-wide properties 122
Code signing 123
Organizer 124
Summary 125
Appendix: Conditional Execution and Interface Designing 127
More?.Swift! 127
Differences between iOS 7.x and 8.x SDK 132
Location services 132
Conditional execution 134
Displaying alerts 135
Showing an alert with ActionController 136
Showing ActionSheet with AlertController 136
Designing in Interface Builder 138
Adaptive UI 138
Summary 140
Index 141

[ iv ]
Preface
Welcome to Xcode 6 Essentials. Development has moved on from the realm of
computer science students to practically everyone. A couple of decades ago,
computers were expensive and hard to use and now everyone has one in their
pockets. Similarly, developmental tools have also changed and made life easier and
allowed people from many other aspects to get with developing. With the popularity
of iOS devices and Macs, the lure of being the App Store millionaire appeals to one
and all. With a growing number of developers using Xcode, Apple has been adding
a lot of features to it. In 2014, Apple released Xcode 6 and Swift. This book will cover
using Xcode, and the language of choice is Swift. This book will take the reader
through the various aspects of Xcode that might be important to use. The book
employs a combination of a step-by-step approach and a theory approach to help
the reader develop.

What this book covers


Chapter 1, Introduction to Xcode, introduces what Xcode is all about. It helps you
install Xcode, if you do not have it on your system, and set it up for use.

Chapter 2, Tour of Xcode, offers a quick tour of the Xcode UI, the various panels,
windows, and settings. This is what you will interact with on a regular basis
when developing. It is helpful to know the shortcuts, what each displays, and
how to activate or deactivate the windows.

Chapter 3, Playgrounds, takes you through a quick journey of Swift, allowing you
to learn Swift interactively using the new feature called Playgrounds. This allows
you to see the results of your commands and variables; your code is run in the
background with no need to compile and run it.
Preface

Chapter 4, Interface Builder, introduces Interface Builder and Storyboards. It further


helps non-developers or beginners to create applications with little to no code. This
can also be used to create functional mock-ups as required.

Chapter 5, Custom Controls, introduces another new feature added to Xcode: the
inclusion of custom controls and live previews. This chapter helps you understand
the stub of a custom control and then add code. It further explains how to create
this as a framework.

Chapter 6, Debugging, helps you as you progress and write your code, given the
possibility of errors creeping in. Powerful debugging tools are introduced; they
will help you understand where to look for basic help and will set up breakpoints,
monitor variables, and quick look values.

Chapter 7, Building and Running, helps you understand the next step after creating
your application: packaging it for distribution to the App Store. After going through
this chapter, you will have run a full life cycle introduction to creating an application
for iOS devices using Xcode.

Appendix, Conditional Execution and Interface Designing, has some interesting gotchas
and tips for using Xcode more efficiently and also learning how the current versions
differ from previous versions of Xcode and SDK.

What you need for this book


To be able to run the code and work through the chapter step-by-step, you will need
the following:

• An Apple computer running OS X 10.9 or higher


• Xcode 6.x installed on this Apple computer

Who this book is for


This book is aimed at intermediate developers who have little to no experience with
iOS SDK. It will also be useful to those who want to get up-to-speed with the new
features of Xcode briefly. A basic understanding of programming logic is necessary
and any experience with iOS is beneficial. It also introduces and uses Swift, a new
language, and will be helpful to those who want a quick introduction to Swift.

[2]
Preface

Conventions
In this book, you will find a number of styles of text 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:
"New UIAlertController is introduced to replace the older UIAlertView."

A block of code is set as follows:


var name: String = "XCode Esentials"
var version: Int = 1.0
var title = "\(name) - ver (\version)"
println("The book is \(title)")

When we wish to draw your attention to a particular part of a code block, the
relevant lines or items are set in bold:
var width: Int = 200
var height: Int = 200
@IBInspectable theColor: UIColor = UIColor.redColor()
var title: String = "Untitled"

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


# po UIScreen().bounds

New terms and important words are shown in bold. Words that you see on the
screen, in menus or dialog boxes for example, appear in the text like this: "Clicking
on the Next button moves you to the next screen."

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

[3]
Preface

Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or may have disliked. Reader feedback is important for us
to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to feedback@packtpub.com,


and mention the book title via 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 on 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 all Packt books you have purchased
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.

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 would 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 on our website, or added to any list
of existing errata, under the Errata section of that title. Any existing errata can be
viewed by selecting your title from http://www.packtpub.com/support.

[4]
Exploring the Variety of Random
Documents with Different Content
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookultra.com

You might also like