This document provides instructions for installing and using Xcode on Mac computers. It summarizes that there will be no computer science lecture the following week, and that Xcode is now available on library Macs. It then demonstrates how to install Xcode from the App Store, create a new project, write and run sample code, and use features like autocompletion, static analysis, and the debugger.
1. 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
2. News
There will be no CSLP lecture next week. The next CSLP lecture will
be on Friday 2nd November.
As of Tuesday, Xcode is now available on all the Open Access Lab
Apple Macs in the Main Library in George Square.
If you are developing on the Macs in the library you do not need to
install 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
3. Xcode is available from the App Store
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 3 / 47
4. Click to install
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 4 / 47
5. Supply your Apple ID password
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 5 / 47
6. The button will change to “Installing”
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 6 / 47
7. Foo
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 7 / 47
8. Accept the License Agreement
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 8 / 47
9. Some components may be updated
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 9 / 47
28. Static analysis warns about code problems
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 28 / 47
29. Autocompletion works on literals too
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 29 / 47
30. Deliberately seeding a bug, overwriting a needed value
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 30 / 47
31. Static analysis warns about format string errors
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 31 / 47
32. Fixing the format string error
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 32 / 47
33. Running the code (first time)
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 33 / 47
36. Output in console
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 36 / 47
37. Using static analysis to find errors (choose Analyze)
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 37 / 47
38. Errors detected: value stored to ‘s’ is never read
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 38 / 47
39. Xcode decides to download libraries
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 39 / 47
40. Xcode decides to download libraries
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 40 / 47
41. Decide to initialise string
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 41 / 47
42. Looking for appropriate init method
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 42 / 47
43. Looking for appropriate init method (initWithString: ?)
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 43 / 47
44. Using “initWithString:” with a literal is redundant
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 44 / 47
46. Code compiles without warnings — even with Analyze
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 46 / 47
47. Produces expected result
Stephen Gilmore (School of Informatics) Computer Science Large Practical Friday 19th October, 2012 47 / 47