getting started with xcode

Post on 12-Nov-2014

1.906 Views

Category:

Education

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Installing Xcode and writing your first simple program. Shows the usefulness of static analysis.

TRANSCRIPT

Computer Science Large Practical:

Programming with Xcode

Stephen Gilmore

School of Informatics

Friday 19th October, 2012

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 1 / 47

News

There will be no CSLP lecture next week. The next CSLP lecture willbe on Friday 2nd November.

As of Tuesday, Xcode is now available on all the Open Access LabApple Macs in the Main Library in George Square.

If you are developing on the Macs in the library you do not need toinstall Xcode.We see first how to install Xcode if you are working on your (Mac)laptop.

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 2 / 47

Xcode is available from the App Store

shot 2012-10-18 at 10.00.38.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 3 / 47

Click to install

shot 2012-10-18 at 10.00.49.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 4 / 47

Supply your Apple ID password

shot 2012-10-18 at 10.01.00.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 5 / 47

The button will change to “Installing”

shot 2012-10-18 at 10.01.22.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 6 / 47

Foo

shot 2012-10-18 at 10.06.58.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 7 / 47

Accept the License Agreement

shot 2012-10-18 at 10.07.19.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 8 / 47

Some components may be updated

shot 2012-10-18 at 10.07.28.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 9 / 47

Requires system permission

shot 2012-10-18 at 10.07.36.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 10 / 47

Installing ...

shot 2012-10-18 at 10.07.53.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 11 / 47

Installing ...

shot 2012-10-18 at 10.08.03.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 12 / 47

Installation complete

shot 2012-10-18 at 10.08.27.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 13 / 47

Welcome screen

shot 2012-10-18 at 10.08.37.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 14 / 47

Create a new project

shot 2012-10-18 at 10.08.53.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 15 / 47

Many options, including iOS projects

shot 2012-10-18 at 10.09.04.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 16 / 47

Choose an OS X application

shot 2012-10-18 at 10.09.26.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 17 / 47

Choose a command-line tool

shot 2012-10-18 at 10.09.32.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 18 / 47

Choose options

shot 2012-10-18 at 10.09.49.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 19 / 47

Choose options

shot 2012-10-18 at 10.10.16.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 20 / 47

Choose Foundation for Objective-C

shot 2012-10-18 at 10.10.24.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 21 / 47

Can choose to create a git repository

shot 2012-10-18 at 10.10.52.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 22 / 47

Project main screen

shot 2012-10-18 at 10.11.36.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 23 / 47

Project has sample “Hello World” code

shot 2012-10-18 at 10.13.15.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 24 / 47

Autocompletion suggests options

shot 2012-10-18 at 10.19.09.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 25 / 47

Autocompletion suggests options

shot 2012-10-18 at 10.19.33.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 26 / 47

Autocompletion suggests options

shot 2012-10-18 at 10.19.42.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 27 / 47

Static analysis warns about code problems

shot 2012-10-18 at 10.20.48.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 28 / 47

Autocompletion works on literals too

shot 2012-10-18 at 10.21.03.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 29 / 47

Deliberately seeding a bug, overwriting a needed value

shot 2012-10-18 at 10.23.43.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 30 / 47

Static analysis warns about format string errors

shot 2012-10-18 at 10.23.43.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 31 / 47

Fixing the format string error

shot 2012-10-18 at 10.23.51.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 32 / 47

Running the code (first time)

shot 2012-10-18 at 10.24.10.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 33 / 47

Requires authentication

shot 2012-10-18 at 10.24.21.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 34 / 47

Build succeeded

shot 2012-10-18 at 10.24.34.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 35 / 47

Output in console

shot 2012-10-18 at 10.24.48.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 36 / 47

Using static analysis to find errors (choose Analyze)

shot 2012-10-18 at 10.25.13.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 37 / 47

Errors detected: value stored to ‘s’ is never read

shot 2012-10-18 at 10.25.22.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 38 / 47

Xcode decides to download libraries

shot 2012-10-18 at 10.27.33.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 39 / 47

Xcode decides to download libraries

shot 2012-10-18 at 10.28.04.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 40 / 47

Decide to initialise string

shot 2012-10-18 at 10.29.38.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 41 / 47

Looking for appropriate init method

shot 2012-10-18 at 10.30.10.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 42 / 47

Looking for appropriate init method (initWithString: ?)

shot 2012-10-18 at 10.30.18.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 43 / 47

Using “initWithString:” with a literal is redundant

shot 2012-10-18 at 10.31.17.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 44 / 47

Checking documentation

shot 2012-10-18 at 10.32.14.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 45 / 47

Code compiles without warnings — even with Analyze

shot 2012-10-18 at 10.34.39.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 46 / 47

Produces expected result

shot 2012-10-18 at 10.35.20.png

Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 47 / 47

top related