xcode, basics and beyond

25
Xcode Basics and Beyond cocoaheads.be

Upload: rsebbe

Post on 15-May-2015

4.822 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Xcode, Basics and Beyond

XcodeBasics and Beyond

cocoaheads.be

Page 2: Xcode, Basics and Beyond

Foreword• The goals of this talk are

• to give some starting points• to present somewhat more specific details of interest

• It is not an exhaustive presentation of Xcode

• For more information on a specific subject, please refer to any of the following:• Documentation• Mailing Lists / Forums• Google

Page 3: Xcode, Basics and Beyond

Background• What is Xcode?

• Appleʼs IDE for Mac and iPhone/iPad development• History

• Roots in NeXTStep, late 80ʼs, early 90ʼs (PB)• Introduced in 2003, as a replacement for good old Project

Builder• Evolves over time, now at version 3.2 (April 2010)

• How to get it?• Comes with Snow Leopard DVD• Available for free from ADC (online registration)

Page 4: Xcode, Basics and Beyond

Main Features• Build System (~Makefile)

• dependencies, command-line, distributed build across network, configuration of app targets, compiler integration...

• Source Code Editor• Code completion and coloring, symbol indexing,

navigation, ...• Debugger

• Tight gdb integration, step by step, runtime variable inspection, remote debug...

• Documentation• Contextual help, guides, reference.

• Organizer• Projects repository + Device browser

Page 5: Xcode, Basics and Beyond

Basics

Page 6: Xcode, Basics and Beyond

Introduction• What is an App? (developer point of view)

MyApp.app/Contents/

MacOS/MyApp

Resources/MyApp.icnsimage1.tiffen.lproj/

MainWindow.nibfr.lproj/

MainWindow.nib

BUILD

Page 7: Xcode, Basics and Beyond

Creating an App: Fast Start• Keep head out of water, dive only when needed.• Create a Project from a Template

• Many pre-configured project. Use them as starting point.

• Build and Run. There you go.

Page 8: Xcode, Basics and Beyond
Page 9: Xcode, Basics and Beyond

Xcode Project• Anatomy of an Xcode project

Target A: Framework Target B: Application

Sources.m, .h, .py

Resources.tiff, .aiff, .png, .strings

etc.

Sources.m, .h, .py

Resources.tiff, .aiff, .png, .strings

etc.

Page 10: Xcode, Basics and Beyond

Targets• You need one to build an app, framework, library• Basically, a target keeps track of

• all needed files (sources, resources), • external library dependencies, • settings to build

• A target is composed of “Build Phases”• Sequence of operation to create a product

• Compile sources + Link• Copy resources in app bundle• etc.

Page 11: Xcode, Basics and Beyond

Build Settings• Configuration of target, compiler, linker settings...• Inheritance (order is important)

• Command Line• Target• Project

• 2 Common Configurations: Debug & Release• Debug

• Removes code optimization (runs slower)• Debugging symbols• Builds only one architecture

• Release• Optimizes code (runs faster)• Removes debugging symbols• Builds as universal binary

• Define new ones for iPhone (Ad Hoc, App Store Distribution)

Page 12: Xcode, Basics and Beyond
Page 13: Xcode, Basics and Beyond

Demo #1

Page 14: Xcode, Basics and Beyond

Beyond Basics

Page 15: Xcode, Basics and Beyond

Focus on Efficiency• Make all you can to be productive.

• Efficient Navigation (Key / Mouse)• Code Reuse through Cross Project Depʼs• Editor Scripts• Config Files• Smart Debugging• Task Automation

Page 16: Xcode, Basics and Beyond

Efficient Navigation• Keyboard Navigation

• Cmd-Double-Click, Opt-Double-Click: go to def. / go to doc.• Cmd-0: Project window• Cmd-Shift-E: Maximize Editor• Cmd-B: Build, Cmd-Shift-B: Show build results• Cmd-R: Run, Cmd-Shift-R: Show run window• Cmd-Y: Debug, Cmd-Shift-Y: Show debugger• Cmd-Ctrl-O: Show Organizer Window• Opt-Cmd-Up: switch to header/source• Cmd-=: Next Warning/Error• Cmd-`: Next Window

Page 17: Xcode, Basics and Beyond

Efficient Navigation• You can customize Xcode shortcuts in the Prefs

• Custom Shortcuts• Cmd-T: Open Quickly (same as Text Mate)

• then type file name or function name !• ESC: complete, Opt-ESC: code sense complete

• then F1 to move cursor to arg• Opt-Cmd-Left/Right: previous/next focus point (+Ctrl for file)• Opt-Cmd-Down: Pop Symbol PopUp (alphabetically sorted !)

Page 18: Xcode, Basics and Beyond

Demo #2

Page 19: Xcode, Basics and Beyond

Code Re-use• Your project may depend on another. Example:

• Framework: CompanyBase.framework• Has common categories to Cocoa types• Handles license and About Panels• ...

• App1, App2 depend on CompanyBase.framework

• To get it to build automatically then:• Import CompanyBase.xcodeproj into App1.xcodeproj• Setup target dependency + link + copy build phase

• Configuration names (Debug, Release) are passed along

Page 20: Xcode, Basics and Beyond

Demo #3

Page 21: Xcode, Basics and Beyond

Smart Debugging• Interactive Debugger

• Step by step, variable inspection (hover)• gdb command invocation

• po, print, call• Useful: apropos word, help command

• Fix and Continue (Mac only!)• Change code while program is running• No need to restart

• Customizing variable display: Data Formatters• Ex: x={$VAR.translation[0]}:v, y={$VAR.translation[1]}:v• This is global• To revert to original, just delete your stuff

Page 22: Xcode, Basics and Beyond

Demo #4

Page 23: Xcode, Basics and Beyond

Task Automation• The main idea is:

★“Fix a bug, then deploy your app with 3 mouse clicks”

• Wouldnʼt it be great if you could automatically• remove headers of embedded framework• prepare signed zip (Sparkle)• have embedded PSDs converted to PNG• encrypt embedded Core Image kernels• upload your app to the server and deploy it

• Well, you can.

Page 24: Xcode, Basics and Beyond

Demo #5 (last one)