Skip to main content

Xcode 5 Developer Reference

Xcode 5 Developer Reference

Richard Wentk

ISBN: 978-1-118-83433-6

May 2014

576 pages

Select type: Paperback

Product not available for purchase


Design, code, and build amazing apps with Xcode 5

Thanks to Apple's awesome Xcode development environment, you can create the next big app for Macs, iPhones, iPads, or iPod touches. Xcode 5 contains gigabytes of great stuff to help you develop for both OS X and iOS devices - things like sample code, utilities, companion applications, documentation, and more. And with Xcode 5 Developer Reference, you now have the ultimate step-by-step guide to it all. Immerse yourself in the heady and lucrative world of Apple app development, see how to tame the latest features and functions, and find loads of smart tips and guidance with this practical book.

  • Shows developers how to use Xcode 5 to create apps for OS X and the whole family of iOS devices, including the latest iPhones, iPads, and iPod touches
  • Covers the Xcode rapid development environment in detail, including utilities, companion applications, and more
  • Includes a companion website with sample code and other helpful files
  • Written by an experienced developer and Apple-focused journalist with solid experience in teaching Apple development

If you want to create killer Apple apps with Xcode 5, start with Xcode 5 Developer Reference!

Preface xix

Acknowledgments xx

Introduction xxi

Part I: Getting Started with Xcode 5 1

Chapter 1: Introducing Xcode 5 3

Understanding the History of Mac Development Tools 3

Looking back at early IDEs 3

Developing Xcode 5

Understanding Xcode 5’s Key Features 6

Moving to Xcode 5 8

Introducing the Xcode 5 editor 9

Working with Interface Builder 14

Exploring code and file management 15

Exploring the debugger 17

Comparing iOS and OS X Development 18

Developing for OS X 18

Developing for iOS 20

OS X and iOS cross-development 21

Summary 22

Chapter 2: Getting and Installing Xcode 23

Selecting a Mac for Xcode 23

Choosing a processor 23

Selecting memory 24

Choosing a monitor 25

Working with disk storage 26

Choosing peripherals 26

Choosing supporting software 27

Getting Started with Development 28

Registering as a developer 29

Choosing a program 30

Accessing developer resources 34

Getting Started with Xcode 36

Installing the Public Version 36

Installing the Developer Version 37

Installing Xcode 38

Creating and organizing project folders 39

Working with multiple versions of Xcode 40

Uninstalling Xcode 40

Summary 40

Chapter 3: Building Applications from Templates 41

Getting Started with Templates 41

Building a project from an application template 44

Looking inside the Application templates 50

Using the OS X Application templates 53

Understanding the iOS Application templates 57

Introducing the Framework and Library templates 65

Introducing the Plug-In templates 66

Introducing the Other templates 67

Customizing Projects and Templates 68

Summary 68

Chapter 4: Navigating the Xcode Interface 69

Understanding the Interface 69

Using the Navigation Area 70

The Project Navigator 71

The Symbol Navigator 74

The Search Navigator 75

The Issue Navigator and the Log Navigator 78

The Test Navigator 80

The Breakpoint Navigator and the Debug Navigator 82

Loading the navigators from menus and keyboard shortcuts 83

Using the Utility Area 84

Displaying file information 84

Using Quick Help 85

Adding custom comments 87

Using the library area 89

Working with the Editor Area 90

Getting started with code editing 90

Introducing build management 94

Summary 97

Chapter 5: Working with Files, Frameworks, and Classes 99

Working with Files and Classes 99

Adding new files to a project 100

Adding a new class 106

Adding new resources 106

Adding miscellaneous other files from the templates 107

Deleting and renaming files 109

Renaming projects 110

Importing existing files 110

Reimporting missing files 111

Working with Groups 112

Moving groups and files 112

Creating a new group 113

Organizing groups 114

Working with Frameworks 114

Adding Apple frameworks 114

Using frameworks 116

Adding other frameworks 117

Summary 117

Chapter 6: Using Documentation 119

Understanding the Apple Documentation 121

Comparing iOS and OS X and their different versions 121

Understanding resource types 122

Using Topics 132

Using frameworks and layers 133

Searching the online documentation 134

Using the Xcode Documentation Viewer 135

Exploring documentation options 136

Browsing the documentation 137

Searching the documentation 139

Using class references 140

Accessing documentation from code 141

Using Other Documentation 143

Summary 144

Chapter 7: Getting Started with Interface Builder 145

Understanding IB 145

Understanding nib files and storyboards 146

Understanding controllers and views 148

Getting Started with IB 148

Introducing IB for iOS 148

Introducing IB for OS X 151

Exploring the utility area 152

Creating a Simple iOS Project with IB 156

Understanding UI design 156

Understanding IB and touch events 157

Adding objects to a view 157

Setting object contents 160

Linking objects to code 168

Creating a universal app 177

Understanding the IB Object Hierarchy 179

Designing without IB 179

Summary 180

Chapter 8: Creating More Advanced Effects with Interface Builder 181

Working with Constraints 181

Introducing constraints and auto-layout 181

Understanding constraints 182

Getting started with constraints 183

Aligning object edges 186

Justifying objects with spacer views 189

Getting Started with Storyboards 194

Understanding segue types 195

Creating a modal segue 195

Adding a view controller subclass 198

Adding a navigation controller 200

Using table views 204

Understanding Placeholders 204

Using File’s Owner 204

Using First Responder 204

Using Exit 207

Subclassing and Customizing Views 207

Creating simple subclasses 207

Working with more advanced subclassing techniques 207

Creating static image backgrounds 209

Creating a colored background 209

Importing an image file 211

Assigning an image file 213

Supporting Non-English Languages 214

Working with Advanced IB Techniques 216

Using tags 216

Converting iPhone projects to the iPad 217

Handling resolution issues 218

Summary 218

Part II: Going Deeper 219

Chapter 9: Saving Time in Xcode 221

Using Code Folding 221

Editing Structure 223

Refactoring Code 225

Using the Refactor menu 226

Using the Edit All in Scope feature 228

Using Code Snippets 229

Inserting a snippet 229

Creating a new snippet 230

Jumping to a Definition 232

Revealing Symbols 233

Summary 233

Chapter 10: Using the Organizer 235

Working with the Library 236

Enabling developer mode 238

Reviewing and managing profiles 238

Finding and installing iOS updates 239

Using device logs 240

Working with screenshots 244

Managing individual devices 246

Working with Projects and Archives 251

Managing Projects 251

Creating Archives 253

Summary 254

Chapter 11: Managing Certificates, Identifiers, and Provisioning Profiles 255

Understanding Provisioning 255

Understanding accounts and team roles 256

Understanding entitlements, devices, and profiles 257

Getting Started with Provisioning 258

Collecting developer resources 260

Creating Certificates and Identities 263

Working on more than one Mac 264

Managing devices 265

Creating Certificates Manually 267

Creating a CSR 268

Summary 270

Chapter 12: Working with Builds, Schemes, and Workspaces 271

Getting Started with the Xcode Build System 271

Creating and organizing a workspace 273

Working with projects and targets 275

Understanding settings and options 276

Working with Schemes and Build Configurations 283

Getting started with build configurations 283

Understanding schemes and build actions 287

Editing schemes 288

Managing schemes, build actions, and targets 297

Summary 300

Chapter 13: Customizing Builds for Development and Distribution 301

Introducing Common Basic Customizations 301

Creating a build for testing and debugging 302

Selecting the Base SDK 302

Setting the minimum supported OS version 303

Including a framework or library in a build 307

Selecting a compiler and C/C++ dialect 308

Controlling warnings 309

Disabling iOS PNG compression 310

Selecting an architecture 310

Changing an app’s name before shipping 311

Creating an App Store Submission 312

Uploading marketing and support materials 312

Building and packaging an iOS project for the App Store 316

Creating a Mac App Store submission 328

Working with iOS Ad Hoc builds 335

Creating and installing an Ad Hoc provisioning profile 335

Creating an Ad Hoc build 335

Distributing an Ad Hoc build 336

Creating Mac Developer ID Builds 338

Setting up a Developer ID build 338

Creating installer packages 340

Summary 340

Chapter 14: Advanced Workspace and Build Management 341

Understanding the Build Process 341

Creating Custom Builds 343

Introducing conditional compilation 343

Using conditional compilation 344

Working with Build Phases 347

Setting up build phases 347

Creating build rules 351

Customizing command-line builds 353

Working with Libraries and Headers 354

Working with workspaces 356

Linking libraries with apps 360

Creating an application in a workspace 361

Summary 367

Chapter 15: Using Version Control 369

Using Manual Version Control 369

Using Snapshots 371

Working with Git Source Control 373

Understanding Git 374

Using Git locally 375

Using Xcode with GitHub 389

Summary 394

Part III: Creating Fast and Reliable Code 395

Chapter 16: Getting Started with Code Analysis and Debugging 397

Checking and Analyzing Code 398

Checking code as you enter it 398

Using Fix-It code tips 399

Using the Static Code Analyzer 400

Getting Started with Debugging 401

Using the Console 403

Creating custom messages 403

Using custom messages 405

Understanding crashes 406

Viewing multiple logs 408

Working with Breakpoints 409

Working with simple breakpoints 409

Using the Variables View 412

Using advanced breakpoint features 419

Advanced Debugging 425

Getting started with command-line debugging 425

Using LLDB outside Xcode 427

Working with crash reports 427

Summary 428

Chapter 17: Testing Code with Instruments 429

Beginning with Instruments 430

Understanding Instruments 431

Exploring the Instruments UI 431

Getting Started with Instruments 438

Creating a leaky test app 439

Profiling an app with Instruments 440

Modifying instrument settings 451

Comparing different runs 452

Saving and loading runs 453

Working with Instruments and Templates 454

Understanding templates 454

Creating a template 455

Creating custom instruments 457

Working with UIAutomation 458

Setting up objects to support automation 459

Creating a test script 460

Getting started with Automation scripting 462

Summary 465

Chapter 18: Working with Testing and Integration 467

Introducing Unit Testing 467

Understanding Unit Testing in Xcode 468

Creating a Simple Unit Test Project 470

Creating a new project that supports unit testing 470

Creating a class for testing 472

Creating a test case 475

Running tests 481

Using Bots for Testing and Integration 483

Getting started with OS X Server 484

Setting up OS X Server 485

Creating bots 493

Monitoring bots 497

Summary 500

Appendix A: Using Developer Tools 501

Appendix B: Getting Started with Optional Tools and Utilities 505

Appendix C: Working with Other Editors 515

Index 533

Xcode 5 Code: Supporting code files Download