Day 1 - How old are you?

Aug 27, 2015 at 04:28 pm, by Pierre Liard

Beginnings are always exciting; nothing is written in stone, everything seems possible. Remember your first day of school, on a new job. You may be apprehensive of the unknown, but mostly you must feel exhilarated of the coming opportunities. It is at least how I feel on this first day of learning Swift 2 in 42 days.

As often when something is new, the first day is like a teaser, or a trailer where the best parts are highlighted. The nitty-gritty generally comes a bit later. The very first lectures were no exception. What interested me is that this tutorial doesn't assume a prior coding knowledge or experience. Neither is a paid software necessary; all the work is done with Xcode 7 downloadable for free from Apple website. Even though it is possible to run Xcode 7 and Swift 2 on a Windows system with a virtual machine application, such as Oracle VM VirtualBox (free), it is not an easy installation. If you google "Xcode on windows", the first link How to develop for Mac or iOS on a PC gives pretty good instructions on how to do it. There are also several videos demonstrating the process. If it is legal or not to copy OS X on a non-Apple computer is a question I won't try to solve it here. I haven't attempted it myself, simply because I have a Mac Book Pro. It's so much better than Windows.

In real life, the treats come generally after having accomplished something, with Rob, they come right at the beginning: free web hosting for 3 months (one year if you leave a review), about 1,000 graphical assets and a copy of his book how to make $10,000 while learning to code. Pretty generous, isn't it? I am not sure if any of Rob''s students was ever able to earn this money, but Rob himself is a living example of his successful strategy - Growth of online education - and has probably inspired other people to follow his path. As for me, it gives me confidence that what I am about to learn is not just another academic teaching, but something based on real experience.

Lecture 8 marks the introduction of the Xcode interface. Time finally to start learning. For those not familiar with coding, Xcode is a integrated development environment (IDE) or, in other words, a software containing different tools for developing software for OS X, iOS and watchOS. When you start a new project, Xcode offers just that:

Xcode new project window

Now what is Swift about? an additional layer on top of Xcode? To make a comparison, Xcode is the playground, and Swift is the game itself. Said differently, Swift is the programming language for iOS, OS X, and watchOS, whereas Xcode is a platform used by Swift to build applications for iPhone, iPad, Apple watch and Mac. It was first introduced in 2014, and the second iteration should be released soon to the general public. Rob's tutorial is consequently based on Swift 2 pre-releases or beta versions. At the time of this writing, I have downloaded beta 6. It should be a pretty stable version, even though the final release may be still introduce new features or changes. This beta status may also create some problems with the lectures whose some have been constructed on prior beta versions.

In any case, the work environment offered by Xcode is relatively simple compared to an IDE like Visual Studio 2015. Nevertheless, if you have never programmed before, it is intimidating:

Xcode IDE

They are three main areas: the left pane show the different files, the center part is the work area and on the right pane you get the context menu, depending on the selection in the main area. It is from this panel that you can drag and drop in the storyboard labels, text boxes, tables, images, etc...

The left panel contains two essentials files: the Main.storyboard that is the graphical interface for the app you're developing, and the ViewController.swift that has the Swift code allowing to control the View Controller. The next shot shows pretty well this structure:

As mentioned by Rob, everything that is dragged in the view controller is called a view. That's it: the stage is now set.

The lectures 9 to 12 explain how to add a label, a text field, a button and an image to the view controller. It consists in selecting in the right panel a object in the library, and to drag and drop it in the main area. It's easy enough it doesn't need any explanation. When done with that, you can immediately preview your work in a simulator replicating an iPhone 6 (or 4 or 5 depending on your choice). Rob never finishes his lectures without giving to his students a mini challenge. In lesson 12, the task was to built the graphic interface of an app called "How old are you?". Nothing is working of course because there is no code yet, but it gave me a feel of what can be done in the view controller. The picture represents the app shown in the simulator:

How old are you?

Tomorrow is another matter: I am about to run some code and building my real first app: Animal ages. I cannot wait!

May 31, 2016 at 05:20 pm, by Pierre Liard

A reader informed me recently of a third way of working with Xcode without owning a Mac computer. Basically you rent a space on a Cloud Mac ( MacinCloud). This allows to develop from any platform for a response time seeming better than running Xcode on a virtual machine. Of course it depends also of your Internet connection speed, but it seems a solution worth to give a shot. For a complete reference, see how to run Xcode on Windows.

Leave a comment

Login to comment a post