xcode® 5 - gbv · developingxcode 5 understandingxcode5's keyfeatures 6 movingto xcode5 8...

9
Xcode® 5 I 111 ^3fe IT ^fll^ 1^ ^fc

Upload: others

Post on 12-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Xcode® 5 - GBV · DevelopingXcode 5 UnderstandingXcode5's KeyFeatures 6 Movingto Xcode5 8 Introducing theXcode5editor 9 WorkingwithInterface Builder 14 Exploringcodeandfile management

Xcode® 5

I 111 ^3fe IT ^fll^ 1^ ^fc

Page 2: Xcode® 5 - GBV · DevelopingXcode 5 UnderstandingXcode5's KeyFeatures 6 Movingto Xcode5 8 Introducing theXcode5editor 9 WorkingwithInterface Builder 14 Exploringcodeandfile management

ContentsPreface xix

Acknowledgments. — xx

Introduction xxi

Part I: Getting Started with Xcode 5 1

Chapter 1: Introducing Xcode 5 3

Understanding the History ofMac 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 theXcode 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

OSX 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

xi

Page 3: Xcode® 5 - GBV · DevelopingXcode 5 UnderstandingXcode5's KeyFeatures 6 Movingto Xcode5 8 Introducing theXcode5editor 9 WorkingwithInterface Builder 14 Exploringcodeandfile management

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 XApplication templates 53

Understanding the iOS Application templates 57

Introducing the Framework and Librarytemplates 65

Introducing the Plug-In templates 66

Introducing the Other templates 67

Customizing Projects and Templates 68

Summary68

Chapter 4: Navigating the Xcode Interface 69

Understanding the Interface 69

Using the Navigation Area 70

The Project Navigator71

The Symbol Navigator 74

The Search Navigator 75

The Issue Navigatorand the Log Navigator 78

The Test Navigator 80

The Breakpoint Navigator andthe Debug Navigator 82

Loadingthe navigators from menus and keyboard shortcuts 83

Using the Utility Area84

Displaying file information 84

Using Quick Help 85

Adding custom comments 87

Using the library area89

Working with the Editor Area 90

Getting started with code editing 90

Introducing build management 94

Summary97

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 resources106

Adding miscellaneousother files from thetemplates 107

Deleting and renaming files 109

Renaming projects110

Importing existing files 110

Reimporting missing files 111

Workingwith Groups112

Moving groups and files 112

Creating a new group113

Organizing groups114

Page 4: Xcode® 5 - GBV · DevelopingXcode 5 UnderstandingXcode5's KeyFeatures 6 Movingto Xcode5 8 Introducing theXcode5editor 9 WorkingwithInterface Builder 14 Exploringcodeandfile management

Workingwith 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 Ul 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

Page 5: Xcode® 5 - GBV · DevelopingXcode 5 UnderstandingXcode5's KeyFeatures 6 Movingto Xcode5 8 Introducing theXcode5editor 9 WorkingwithInterface Builder 14 Exploringcodeandfile management

Aligning object edges

Justifying objects with spacer views

Getting Started with Storyboards

Understanding segue types

Creating a modal segue

Adding a view controllersubclass

Adding a navigation controller

Using table views

Understanding Placeholders

Using File's Owner

Using First ResponderUsing Exit

Subclassing and Customizing Views

Creating simple subclasses

Working with more advanced subclassing techniquesCreating static image backgrounds

Creating a colored backgroundImporting an image file

Assigning an image file

Supporting Non-English Languages

Working with Advanced IB TechniquesUsing tags

Converting iPhone projects to the iPad

Handling resolution issues

Summary

Part II: Going Deeper 219

Chapter 9: Saving Time in Xcode .2

Using Code FoldingEditing Structure

Refactoring Code

Using the Refactormenu

Using the Edit All in Scopefeature

Using Code SnippetsInserting a snippet

Creating a new snippetJumpingto a Definition

Revealing SymbolsSummary

Chapter 10: Using the Organizer... .2

Working with the LibraryEnabling developer mode

Reviewing and managing profiles

Page 6: Xcode® 5 - GBV · DevelopingXcode 5 UnderstandingXcode5's KeyFeatures 6 Movingto Xcode5 8 Introducing theXcode5editor 9 WorkingwithInterface Builder 14 Exploringcodeandfile management

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 schemesand 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

Page 7: Xcode® 5 - GBV · DevelopingXcode 5 UnderstandingXcode5's KeyFeatures 6 Movingto Xcode5 8 Introducing theXcode5editor 9 WorkingwithInterface Builder 14 Exploringcodeandfile management

Creating an App Store Submission

Uploading marketing and support materials

Building and packaging an iOS project for the App Store

Creating a Mac App Store submission

Working with iOS Ad Hoc builds

Creating and installing an Ad Hoc provisioning profile

Creating an Ad Hoc build

Distributing an Ad Hoc build

Creating MacDeveloper ID Builds

Setting up a Developer ID build

Creating installer packages

Summary

Chapter 14: Advanced Workspace and Build Management 3

Understanding the Build Process

Creating Custom Builds

Introducing conditional compilationUsing conditional compilation

Working with Build Phases

Setting up build phases

Creating build rules

Customizing command-line builds

Working with Libraries and Headers

Working with workspaces

Linking libraries with apps

Creating an application in a workspace

Summary

Chapter 15: Using Version Control 3

Using Manual Version Control

Using Snapshots

Working with Git Source Control

Understanding Git

Using Git locallyUsing Xcode with GitHub

Summary

Part III: Creating Fast and Reliable Code 31

Chapter 16: Getting Started with Code Analysis and Debugging 3

Checking and Analyzing Code

Checking code as you enter it

Using Fix-It code tips

Using the Static Code Analyzer

Page 8: Xcode® 5 - GBV · DevelopingXcode 5 UnderstandingXcode5's KeyFeatures 6 Movingto Xcode5 8 Introducing theXcode5editor 9 WorkingwithInterface Builder 14 Exploringcodeandfile management

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

Workingwith 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 Ul 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 UlAutomation 458

Setting up objects to supportautomation 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 newproject that supports unit testing 470

Creating a class for testing 472

Creating a test case 475

Running tests 481

Page 9: Xcode® 5 - GBV · DevelopingXcode 5 UnderstandingXcode5's KeyFeatures 6 Movingto Xcode5 8 Introducing theXcode5editor 9 WorkingwithInterface Builder 14 Exploringcodeandfile management

*jw>-

Using Bots for Testing and Integration 483

Getting started with OS XServer 484

Setting up OS X Server 485

Monitoring bots 497

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