With the release of Xcode 6 in 2014, it is possible to build Swift applications for iOS and OS X and submit them to the App Store for publication. This chapter will present both a single view application and a master-detail application, and use these to explain the concepts behind iOS applications as well as introduce classes in Swift.
This chapter will present the following topics:
AppDelegate
and ViewController
classesAn iOS application is a compiled executable, along with a set of supporting files in a bundle. The application bundle is packaged into an archive file for installing onto a device or uploading to the App Store.
Xcode can be used to run iOS applications in a simulator, but running an application on a device requires a developer signing key, which is included as part of the iOS developer program at https://developer.apple.com.
Most iOS applications to date have been written in Objective-C, a crossover between C and Smalltalk. With the advent of Swift, it is likely that many developers will move at least parts of their applications to Swift for performance and maintenance reasons. Although Objective-C is likely to be around for a while, it is clear that Swift is the future of iOS development, and probably OS X as well.
Applications contain a number of different types of files, which are used both at compile time and also at runtime. These files include:
Info.plist
file, which contains information about which languages the application is localized for, what the identity of the application is, and the configuration requirements, such as the supported interface types (iPad, iPhone, and Universal) and orientations (Portrait, Upside Down, Landscape Left, and Landscape Right).xib
extension, which contain user interface screens (which supersedes the previous .nib
files).xcassets
extension, which store groups of related icons at different sizes, such as the application icon or graphics for display on screen (which supersedes the previous .icns
files).storyboard
extension, which are used to coordinate between different screens in an application.swift
files that contain application code