2. 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
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 (~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
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-configured 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 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.
11. 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)
15. 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
16. 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
17. 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 !)
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
• Configuration 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.