Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Application Development in iOS 7
Application Development in iOS 7

Application Development in iOS 7:

By Kyle Begeman
€18.99 €12.99
Book May 2014 126 pages 1st Edition
eBook
€18.99 €12.99
Print
€22.99
Subscription
€14.99 Monthly
eBook
€18.99 €12.99
Print
€22.99
Subscription
€14.99 Monthly

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 : May 19, 2014
Length 126 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781783550319
Category :
Languages :
Table of content icon View table of contents Preview book icon Preview Book

Application Development in iOS 7

Chapter 1. Xcode 5 – A Developer's Ultimate Tool

With the release of iOS 7, Apple has also provided developers with a completely updated version of Xcode, that is, its Integrated Development Environment (IDE). Xcode 5 is a major step forward, complete with more tools and features available than ever before.

Understanding the powerful features of your IDE is the key to high productivity and overall ease of development. In this chapter, we will explore all these new features and learn how they will assist you in writing your apps for iOS 7.

The new user experience


Xcode 5 features many welcomed changes to its overall user experience in the form of subtle design enhancements and under-the-hood optimization. Take a few minutes to play with the new IDE, and you will see that although not much has moved, the cleaner UI provides a much less distracting environment to work in. Shorter toolbars and easy-to-see highlighted buttons help keep your content front and center.

The following screenshot shows how the window of the new IDE looks:

Features such as Open Quickly have been trimmed down in size, yet improved in functionality. Navigating to File | Open Quickly or using the keyboard shortcut command + shift + O will open a simplified single-line search bar in the middle of your screen. As you type an option, search results are returned much more quickly and prioritized based on relevance. Each result also features detailed data on your query such as the file and line number. The following screenshot shows an example of search results:

For a more refined search, you may want to select the search navigator from the navigator panel or use the keyboard shortcut command + 3. Typing a search query and pressing enter will prompt Xcode 5 to perform a project-wide search by default. The results will be displayed in the navigator below the search bar, and also includes new options for refinement. Selecting the In Project button (here, Project is the name of your project) will allow you to specify individual folders to perform the search in. For even more flexibility, the new search navigator will allow you to build custom search scopes that can be saved for future usage. The following screenshot shows the difference between when we do and when we do not select the In FoodAndMe button (in this case, FoodAndMe is the project name):

Top-level documentation


Apple provides some of the most in-depth SDK documentation of any development platform. Access to this documentation is possibly one of the most important aspects of iOS development. Previous versions of Xcode always had access to documentation; however, Xcode 5 takes a more accessible approach with its top-level documentation. It's important to note that an Internet connection is required unless you predownload the documentation from Apple. This can be done by navigating to Xcode | Preferences | Downloads.

Go to the menu bar and navigate to Help | Documentation and API Reference. Xcode 5 will show a separate window that has been designed to streamline the search and display of all of the documentation. Apple has built this documentation to work for you. As you type, Xcode will display suggestions in the form of API references, SDK guides, and even Sample Code related to your search.

The new documentation view also provides support for tabs, allowing you to view multiple pieces of documentation simultaneously. As you browse through the results, you may see a dynamic table of contents by clicking on the table of contents button immediately to the left-hand side of the search bar. The table of contents will automatically update based on the document you are currently viewing.

Additionally, the new documentation has built-in bookmarking, which allows you to save your most frequently viewed resources. To the right of the search bar, you will see a share button. Clicking on this button will show a menu with options to share or bookmark the current reference.

You may have also noticed a small bookmark icon on the left-hand side of each title or heading while scrolling through the documentation. You can even save specific sections of any API reference rather than saving the entire document. All of your bookmarks can be viewed in the navigator by clicking on the navigator button immediately on the left-hand side of the table of contents button. This view will also allow you to browse the entire documentation library at a glance. Combine this with the previous ability of pressing the alt key and clicking on any code to display an inline summary and linking from the code to full documentation, and then you'll have robust documentation integration!

Debugger and debug gauges


Debugging with Xcode 5 has been greatly improved thanks to many new features added to the debugger. Apple has completely switched from the previous GDB engine to the much more powerful LLDB engine. This allows breakpoint flexibility, inline variable previews, and the finding of variable values more easily.

If you have ever debugged a project using breakpoints, you will notice some changes in the way Xcode 5 manages its breakpoints. Breakpoints are still created by clicking directly on the required line number. These breakpoints can then be enabled or disabled by clicking on them directly or using the breakpoints button that has been moved to the debug toolbar found at the bottom of the Xcode window.

Each breakpoint may also be configured to respond conditionally. By default, code will stop once it reaches a breakpoint. Once you set conditions, however, breakpoints will be ignored unless these conditions are met. You can edit these conditions by right-clicking on an individual breakpoint and selecting Edit Breakpoint. From here, set your conditions and resultant actions. These actions can include logging a message to the console, running an AppleScript or Shell Script, and even playing a sound.

Another great feature of Xcode 5's debugger is the ability to preview variables and objects during debugging using data tips. While debugging your application, hover your mouse over a variable and its value will automatically appear below your cursor. This works for standard data types, such as strings, numeric types, and Boolean types.

Data tips are very powerful when it comes to objects as well. For instance, while in debug mode, hover your mouse over an image, and a summary of information will appear about this object. Selecting the eye-shaped icon will allow you to preview the actual image right in code, as shown in the following screenshot:

Properly debugging any application also involves monitoring system resources to ensure your code is as optimized as possible. Xcode 5 introduces debug gauges, a lightweight and embedded version of some useful instruments' tools. Because debug gauges are integrated into Xcode 5, they are able to run alongside the application at all times while allowing you to observe CPU, Memory, iCloud, Energy, and OpenGL ES resources.

Debug gauges can be found through the debug navigator and will begin running automatically once you run a project. The previously mentioned resources are displayed in an easy-to-read visual graph so that you can monitor your application's performance at a glance and in real time. Additionally, access to the complete instruments software is just a single click away, which is achieved by clicking on the Profile in Instruments button shown in the following screenshot:

Automatic configuration with accounts and capabilities


Apple provides a wide variety of useful services that can be included in any application. Enabling your application to support these services has always been a hassle due to the number of tasks a developer is required to manually set up. These include adding entitlements, such as the App ID, linking frameworks to the project, and adding required fields to the projects .plist file. Additionally, each of these services has its own requirements, which means that supporting multiple services would require different steps to complete.

With the introduction of Xcode 5, Apple has made these struggles a thing of the past using automatic configuration. With automatic configuration, all a developer needs is an Apple ID linked to a developer account.

Navigate to Xcode | Preferences and select the Accounts section (new in Xcode 5). From here, you can add all your Developer Program Apple IDs and view details related to each account. Clicking on the + button located on the left-hand side panel will give you the option to add a new Apple ID. Doing so will provide a direct connection between Xcode 5 and the Apple Developer Portal. Once logged in, click on the View Details... button at the bottom-right corner of the screen. A new window will appear with details of all code-signing identities and provisioning profiles attached to the selected account.

Under the General tab in the project editor, you will see a new option, Team, found in the Identity section. Selecting this option will show you a list of identities related to the account we previously added. By selecting your respective signing identity, Xcode 5 will be able to verify whether you have all proper provision profiles and even offer to create them for you if required.

Potentially, the biggest advancement provided by automatic configuration is the Capabilities tab (new in Xcode 5) found in the project editor. This streamlined approach will allow you to configure specific platform features, such as iCloud, In-App Purchases, and Game Center, without having to visit the developer portal as shown in the following screenshot. Xcode 5 will automatically configure the provisioning profile, add App ID entitlements, and link all required frameworks for you, automatically:

If you prefer to set up your features and capabilities the old way, you may still do so in the Apple Developer Portal.

Source control


Source control is widely used by large teams and individual developers alike. It provides an extremely useful way to track changes to code and revert back to stable builds of a project with version control. Teams of developers may work separately on individual components by creating and managing a copy of the code (called a branch) without overwriting another team member's code. The change will later be merged while simultaneously tracking all the changes made to the code base.

Source control is not a new feature of Xcode 5; however, Apple has decided to provide easier access to its functionality by creating a top-level menu item. Selecting it will display a drop-down menu with one-click access to most of the source control commands, such as commit, push, and pull. Hovering over Working Copies will open a new submenu that allows you to switch between branches, create a new branch, or merge branches. The following screenshot shows this submenu:

In addition to local source control on your computer, Xcode 5 also supports the ability to connect directly to remote repositories hosted on popular sites, such as GitHub. Open preferences and navigate to the Accounts tab once again. This time, after clicking on the + button, select Add Repository. Once you have entered the proper repository address, Xcode 5 will connect the repository, thus allowing you to access it remotely.

Asset catalogs


Every project you create will contain at least a few image files in the form of launch images and application icons as well as other UI elements. Asset catalogs serve two major purposes in Xcode 5. These include automation of icon and launch image naming conventions and grouping image files together in a single location.

Asset catalogs are represented as a separate group with a blue folder in the project navigator. By default, each new project created will include the default Images.xcassets item. You may also create your own asset catalogs for further organization based on personal preference.

Xcode 5 requires each of the launch image files and icon image files to be named appropriately based on the device and/or resolution the image will be used for. When selecting the Images.xcassets item, you will see a number of empty slots waiting for images to be added. Each slot has a description of what image it holds. Dragging from your computer into Xcode 5 on the respective slot will add the image to your project and automatically configure all the naming conventions. The following screenshot shows the Asset Catalog window:

If you wish to add any additional images related to your project, you can simply drag-and-drop them into the Asset Catalog window, and Xcode 5 will take care of the rest. Both high-resolution (2x) and standard-resolution (1x) image files will be grouped together in their own image set with a common name. You still must provide both the low-resolution and high-resolution images yourself. Xcode 5 does not automatically scale them for you: it simply groups them. The value for this name can be changed to any value and will be used in code to access the associated images regardless of the actual filename.

Quick build device selection


Developing applications for multiple devices requires consistent device-specific testing. The iOS simulator included in the iOS SDK provides simulation for all Apple devices. With Xcode 5, selecting the proper device to build for has also been streamlined into a single drop-down option found on the toolbar.

Clicking on the name of the current device on the left of the toolbar will provide a drop-down menu. Any and all physical devices connected to your computer will appear on the top of the list (you may have to scroll up to see them), and all standard iOS simulator devices will appear below.

Simply select the device you wish to test for, and click on Run. The simulator will launch and switch to the selected device. The following screenshot lists the devices in the drop-down menu:

Storyboard previews


Up until now, writing applications that supported previous versions of iOS mostly consisted of updating API calls and minor coding conventions. With iOS 7, Apple has drastically changed the design of all standard UI objects. Knowing the size, position, and layout of all objects for both iOS 7 and previous versions is very important to maintaining a consistent user experience. This is where storyboard previews come in.

In order to use storyboard previews, you must select the assistant editor and navigate to the view you wish to preview (usually a .xib or .storyboard file). Select the Related Files menu option, navigate to Preview, and select the .xib or .storyboard file you wish to preview, as shown in the following screenshot:

You will see an identical preview of your view on the right-hand side of the assistant editor. In the bottom-right corner of the view, you will see a button that says iOS 7.0 and Later. Click on it, and then select iOS 6.1 and Earlier as shown in the following screenshot:

Your view will now display all of its UI elements as they will appear in iOS 6 or earlier. This is a very handy tool if you wish to make your app backwards compatible.

Summary


Xcode 5 has more features for developers than ever before, and each tool is designed to give you a more efficient experience while building the best quality apps possible. In this chapter, we learned how to use all of these features, from new debugging tools to automatic configuration. Although we covered a large portion of new Xcode 5 features, you should visit the following link to view Apple's documentation on what's new in Xcode 5: https://developer.apple.com/library/mac/releasenotes/DeveloperTools/RN-Xcode/Introduction/Introduction.html

With each new iOS SDK release, Apple includes some minor and some major updates to the Objective-C programming language. In the next chapter, we will cover the changes made to the Foundation Framework, possibly the most important framework in all of iOS development!

Left arrow icon Right arrow icon

Key benefits

What you will learn

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 : May 19, 2014
Length 126 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781783550319
Category :
Languages :

Table of Contents

15 Chapters
Application Development in iOS 7 Chevron down icon Chevron up icon
Credits Chevron down icon Chevron up icon
About the Author Chevron down icon Chevron up icon
About the Reviewers Chevron down icon Chevron up icon
www.PacktPub.com Chevron down icon Chevron up icon
Preface Chevron down icon Chevron up icon
Xcode 5 – A Developer's Ultimate Tool Chevron down icon Chevron up icon
Foundation Framework – Growing Up Chevron down icon Chevron up icon
Auto Layout 2.0 Chevron down icon Chevron up icon
Building Our Application for iOS 7 Chevron down icon Chevron up icon
Creating and Saving User Data Chevron down icon Chevron up icon
Displaying User Data Chevron down icon Chevron up icon
Manipulating Text with TextKit Chevron down icon Chevron up icon
Adding Physics with UIKit Dynamics Chevron down icon Chevron up icon
Index 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.