Xcode, Basics and Beyond

6,004 views

Published on

Published in: Technology

Xcode, Basics and Beyond

  1. 1. Xcode Basics and Beyond cocoaheads.be
  2. 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. 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. 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
  5. 5. Basics
  6. 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. 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. 8. 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.
  9. 9. 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.
  10. 10. 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)
  11. 11. Demo #1
  12. 12. Beyond Basics
  13. 13. 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
  14. 14. 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
  15. 15. 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 !)
  16. 16. Demo #2
  17. 17. 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
  18. 18. Demo #3
  19. 19. 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
  20. 20. Demo #4
  21. 21. 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.
  22. 22. Demo #5 (last one)
  23. 23. Happy (X)coding ! web: www.creaceed.com email: raphael@creaceed.com cocoaheads.be twitter: @rsebbe

×