xcode, basics and beyond

Post on 15-May-2015

4.822 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

XcodeBasics and Beyond

cocoaheads.be

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

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)

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

Basics

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

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.

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.

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.

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)

Demo #1

Beyond Basics

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

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

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 !)

Demo #2

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

Demo #3

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

Demo #4

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.

Demo #5 (last one)

Happy (X)coding !

web: www.creaceed.comemail: raphael@creaceed.comtwitter: @rsebbe cocoaheads.be

top related