Step into Xcode: Mac OS X Development

Fritz Anderson

買這商品的人也買了...

商品描述

Description:

A Step-by-Step Guide to the Xcode Mac OS Development Environment

Every copy of Mac OS X comes with Xcode, the powerful development suite that Apple uses to build applications ranging from Safari to iTunes. But because Xcode is complex and subtle, even experienced Mac programmers rarely take full advantage of it. Now, Mac developer Fritz Anderson has written the definitive introduction and guide to using Xcode to build applications with any Macintosh technology or language.

Anderson helps you master Xcode's powerful text editor, industry-standard gcc compiler, graphical interactive debugger, mature UI layout and object linkage editor, and exceptional optimization tools. One step at a time, you'll develop a command-line utility, then use Xcode tools to evolve it into a full-fledged Cocoa application. Anderson provides expert guidance on development frameworks, source code management, Core Data modeling, localization, and much more.

Coverage includes

  • Understanding Xcode workflow and the Mac OS X application lifecycle
  • Porting established legacy projects into Xcode
  • Using the Model-View-Controller design pattern to build robust graphical applications
  • Building static libraries and working with Xcode's build system
  • Making the most of bundles and package directories
  • Creating applications compatible with older versions of Mac OS X
  • Creating universal binaries to run on both Intel and PowerPC Macintoshes
  • Adding Spotlight searchability to data files
  • Leveraging Xcode's built-in support for unit testing
  • Using Xcode on makefile-based UNIX development projects

Step Into Xcode's breadth, depth, and practical focus make it indispensable to every Mac developer: current Xcode users upgrading to Xcode 2.1, experienced Mac programmers migrating from CodeWarrior, UNIX/Linux programmers moving to Mac OS X, and even novices writing their first programs or scripts.

 

Table of Contents:

Preface xvii
Part I The Life Cycle of a Mac OS X Application 1
1 Kicking the Tires 3
1.1 First Run 3

1.2 Hello, World 4

1.3 What Went Where 9

1.4 Summary 10

2 Simple Workflow and Passive Debugging 11
2.1 Linear Regression 11

2.2 Plan of Action 13

2.3 A Command Line Tool 14

2.4 Build Errors 15

2.5 Simple Debugging 18

2.6 Summary 21

3 Simple Active Debugging 23
3.1 The Next Step 23

3.2 Active Debugging 24

3.3 Summary 31

4 Compilation: The Basics 33
4.1 Compiling 33

4.2 Linking 36

4.3 Dynamic Loading 38

4.4 Prebinding 39

4.5 ZeroLink 40

4.6 Summary 42

5 Starting a Cocoa Application 43
5.1 Plan of Action 43

5.1.1 Program Tasks 43

5.1.2 Model-View-Controller 43

5.2 Starting a New Project 48

5.3 Implementation: Model 50

5.3.1 DataPoint 50

5.3.2 RegressionModel Class 54

5.3.3 Model: Done 58

5.4 Summary 60

6 A Cocoa Application: Views 61
6.1 Interface Builder 62

6.2 Layout 63

6.3 Sizing 67

6.4 A Split View 71

6.5 Summary 71

7 A Cocoa Application: Controllers 73
7.1 Still in Interface Builder 73

7.2 NSObjectController: Document 75

7.3 NSObjectController: Model 77

7.4 NSArrayController: DataPoints 78

7.5 Value Binding 80

7.6 Actions and Outlets 81

7.7 MyDocument 82

7.8 Application Properties 84

7.9 Building 87

7.10 Summary 87

8 Property Lists 89
8.1 Data Types 89

8.2 Property List Files 90

8.2.1 Writing a Property List 90

8.2.2 Examining Property Lists 100

8.3 Other Formats 106

8.3.1 ASCII Property Lists 106

8.3.2 Binary Property Lists 107

8.4 Text Macros 107

8.5 Summary 113

9 Libraries and Dependent Targets 115
9.1 Adding a Target 115

9.2 Library Design 116

9.3 Modifying Linear 121

9.4 A Dependent Target 123

9.5 Examining the Library 125

9.6 Running the Library 127

9.7 Summary 128

10 File Packages and Bundles 129
10.1 A Simple Package: RTFD 130

10.2 Bundles 132

10.3 Application Bundles 132

10.4 The Info.plist File 134

10.4.1 Keys for All Bundles 135

10.4.2 Keys for Applications 136

10.4.3 Keys for Plug-Ins 138

10.4.4 Keys for Java 139

10.4.5 Keys for Preference Panes 139

10.4.6 Keys for Dashboard Widgets 139

10.5 Summary 140

11 Creating a Custom View 141
11.1 Controller 141

11.2 View 143

11.3 The Delegate Design Pattern 146

11.4 The Custom View 149

11.5 Showing the Window 156

11.6 Testing 157

11.7 Debugging a View 159

11.8 Summary 163

12 Dynamic Libraries and Frameworks 165
12.1 Adding a Framework Target 166

12.2 Framework Structure 171

12.3 Using the Framework 173

12.4 Where Frameworks Go 175

12.5 Private Frameworks 179

12.6 Prebinding 181

12.7 Summary 182

13 Version Control 183
13.1 Setting up a Repository 185

13.2 Controlling Linear 191

13.3 Long Live Linear 194

13.4 Tagging 195

13.5 Summary 198

14 Cross-Development 199
14.1 Cross-Development SDKs 199

14.2 Nib Compatibility 203

14.3 NSTableDataSource 205

14.4 Add, Remove, Compute, and Graph Buttons 208

14.5 Run and Archive 211

14.6 A More Sophisticated Approach 212

14.7 Producing a Universal Binary 212

14.7.1 Auditing for Portability 213

14.7.2 Auditing Linear 214

14.7.3 Building Universal 217

14.7.4 Mixing SDKs 218

14.8 Summary 219

15 Using the Data Modeling Tools 221
15.1 Data Modeling 221

15.2 Revisiting the Model 224

15.2.1 DataPoint 225

15.2.2 Regression 228

15.2.3 MyDocument 232

15.3 Interface Builder 234

15.4 Build and Run 235

15.5 Adding an Entity 237

15.5.1 Adding to the Data Model 237

15.5.2 Human Interface 238

15.5.3 First Run 240

15.5.4 One More Table 241

15.6 Summary 242

16 Spotlight 243
16.1 How Data Gets into Spotlight 243

16.2 Uniform Type Identifiers 246

16.3 The Metadata Plug-In 249

16.3.1 MetaLinear Project Files 249

16.3.2 Packaging the Plug-In 254

16.4 Core Data and Metadata 254

16.5 The Proof of the Pudding 258

16.6 Summary 261

17 Finishing Touches 263
17.2 Avoiding Singularity 264

17.3 Localization 266

17.3.1 Credits.rtf 266

17.3.2 MainMenu.nib 267

17.3.3 MyDocument.nib 267

17.3.4 GraphWindow.nib 269

17.3.5 InfoPlist.strings 270

17.3.6 Trying It Out 271

17.3.7 Localizable.strings 272

17.4 Checking Memory Usage 274

17.5 The Release Build Configuration 276

17.6 Dead-Code Stripping 278

17.7 xcodebuild 279

17.8 Summary 281

Part II Xcode Tasks 283
18 Navigating an Xcode Project 285
18.1 Editor Panes 285

18.1.1 Jumps 285

18.1.2 Code Sense 286

18.1.3 Navigation Bar 287

18.1.4 Editor Modes 289

18.2 Project Find Window 290

18.3 The Favorites Bar 291

18.4 Groups & Files List 292

18.4.1 The Project Group 292

18.4.2 The Targets Group 294

18.4.3 The Executables Group 296

18.4.4 Smart Groups 297

18.4.5 Symbol Smart Group 298

18.5 Class Browser Window 299

18.6 Class Modeler 299

18.7 Project Layout 302

18.7.1 Default Layout 302

18.7.2 All-in-One Layout 303

18.7.3 Condensed Layout 305

18.8 Summary 306

19 Xcode for CodeWarrior Veterans 307
19.1 Losses 307

19.1.1 Speed 307

19.1.2 Syntax Coloring 308

19.1.3 Debugging Templates 308

19.1.4 RAD Tools 309

19.2 Make Yourself at Home 309

19.2.1 The Project Window 309

19.2.2 Key Mapping 311

19.2.3 Build Behavior 312

19.2.4 Window Behavior 313

19.3 Converting a CodeWarrior Project 314

19.3.1 Importing the Project 315

19.3.2 Targets and Configurations 315

19.4 Traps in Conversion 319

19.5 Exporting Symbols 320

19.5.1 #pragma export 320

19.5.2 Another Way 322

19.6 Summary 323

20 Xcode for make Veterans 325
20.1 Xcode Build Variables 327

20.2 Custom Build Rules 328

20.3 Run Script Build Phase 330

20.4 Under the Hood: A Simple Build 331

20.4.1 Copy Structural Files 332

20.4.2 Copy Bundle Resources 333

20.4.3 Compile Sources 333

20.4.4 Linkage (First Architecture) 336

20.4.5 Compile Sources (Second Architecture) 336

20.4.6 Linkage (Second Architecture) 337

20.4.7 Create Universal Binary 337

20.4.8 Compile Data Models 338

20.4.9 Finishing Touch 339

20.5 The xcode build Tool 339

20.6 Settings Hierarchy 340

20.7 Build Configurations 342

20.8 Summary 344

21 More About Debugging 345
21.1 Debugging Techniques 345

21.2 Printing Values 348

21.3 Custom Formatters 349

21.4 Breakpoint Commands 352

21.5 Breakpoint Conditions 354

21.6 Lazy Symbol Loading 355

21.7 Zombies 356

21.7.1 Released-Pointer Aliasing 357

21.7.2 Zombies in Cocoa 359

21.7.3 Zombies in Core Foundation 360

21.8 Summary 361

22 Xcode and Speed 363
22.1 Precompiled Headers 363

22.2 Predictive Compilation 364

22.3 Distributed Builds 365

22.4 ZeroLink 366

22.5 Profect Indexing 367

22.6 Summary 368

23 AppleScript Studio 369
23.1 An AppleScript Application 369

23.2 Unit Testing 377

23.2.1 Adding OC Unit 378

23.2.2 Test Cases 379

23.2.3 Testing Options 383

23.3 Summary 383

24 A Large Project 385
24.1 Graphviz 386

24.2 Preparing the Project 386

24.3 An External Build Project 389

24.4 Debugging a Custom Executable 393

24.5 Performance 396

24.6 A Better Way to Include Files 400

24.6.1 The Script 401

24.6.2 Building the Project Index 404

24.6.3 Compromising with AppleScript 405

24.7 Summary 405

25 Closing Snippets 407
25.1 Miscellaneous Traps 407

25.2 Miscellaneous Tips 409

25.3 Documentation 413

25.3.1 The Documentation Window 414

25.3.2 Documentation Updates 416

Appendix A Installing Xcode 417
A.1 Apple Developer Connection 419

A.1.1 Downloading from ADC 420

A.2 Setting up the Dock 420

Appendix B Some Build Variables 423
B.1 Useful Build Variables 423

B.2 Splitting Build Variables 429

B.3 Source Trees 430

Glossary 433
Index 441