2. Foreword
⢠The goals of this talk are
⢠to give some starting points
⢠to present somewhat more speciďŹc details of interest
⢠It is not an exhaustive presentation of Xcode
⢠For more information on a speciďŹc subject, please
refer to any of the following:
⢠Documentation
⢠Mailing Lists / Forums
⢠Google
3. 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)
4. Main Features
⢠Build System (~MakeďŹle)
⢠dependencies, command-line, distributed build across
network, conďŹguration 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
6. Introduction
⢠What is an App? (developer point of view)
MyApp.app/
Contents/
MacOS/
MyApp
B Resources/
U MyApp.icns
I image1.tiff
L en.lproj/
D MainWindow.nib
fr.lproj/
MainWindow.nib
7. Creating an App: Fast Start
⢠Keep head out of water, dive only when needed.
⢠Create a Project from a Template
⢠Many pre-conďŹgured project. Use them as starting point.
⢠Build and Run. There you go.
8.
9. Xcode Project
⢠Anatomy of an Xcode project
Target A: Framework Target B: Application
Sources Sources
.m, .h, .py .m, .h, .py
Resources Resources
.tiff, .aiff, .png, .strings .tiff, .aiff, .png, .strings
etc. etc.
10. Targets
⢠You need one to build an app, framework, library
⢠Basically, a target keeps track of
⢠all needed ďŹles (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.
11. Build Settings
⢠ConďŹguration of target, compiler, linker settings...
⢠Inheritance (order is important)
⢠Command Line
⢠Target
⢠Project
⢠2 Common ConďŹgurations: 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
⢠DeďŹne new ones for iPhone (Ad Hoc, App Store Distribution)
15. Focus on EfďŹciency
⢠Make all you can to be productive.
⢠EfďŹcient Navigation (Key / Mouse)
⢠Code Reuse through Cross Project Depʟs
⢠Editor Scripts
⢠ConďŹg Files
⢠Smart Debugging
⢠Task Automation
16. EfďŹcient 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
17. EfďŹcient Navigation
⢠You can customize Xcode shortcuts in the Prefs
⢠Custom Shortcuts
⢠Cmd-T: Open Quickly (same as Text Mate)
⢠then type ďŹle 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 ďŹle)
⢠Opt-Cmd-Down: Pop Symbol PopUp (alphabetically sorted !)
19. 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
⢠ConďŹguration names (Debug, Release) are passed along
21. 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
23. 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.