Learning Swift…argh

0

XCode is just so complicated that even the very good Ray Wenderlich Tutorials typically leave something out causing errors. So for the Swift Tutorial Part 2, here are errata:

  1. When you are looking at main.storyboard, the tutorial talks about the navigation Document Outline. This is only visible is you right click on the main.storyboard on the left pane (the Navigation pane). if you are like me and just browsing you won’t see it.
  2. When you want to add a title to the View Controller, it tells you to double click on the title bar. Actually, after you choose Embed In, the selection moves to the navigation bar and even if you try to double click on the view controller title this doesn’t work. Instead, you have to specifically click on the “View Controller” in the navigation pane or the yellow icon at the top and then you can change the text. Just click on the space doesn’t give you focus there for editing.
  3. If you don’t change this text by the way, the tutorial fails with an obscure message, “failed to initialize” because there is no entry point, so beware, you *must* have a title for the View Controller for this to work.
  4. The text field attribute, “Keyboard Type” is way down on the list, in the right pane there is the fourth icon is called the Attributes Inspector (if you leave the mouse on top of the icon the name comes up).
  5. To make all the location changes, you need to be on the fifth icon in the right menu called “Size Inspector”
  6. Sometimes the simulator ignores the call for a decimal keyboard. YOu have to reset the IOS simulator by turning off Hardware/Keyboard/Use Hardware Keyboard.

The second point is that Swift is powerful but you get lots of bizarre messages because when writing a program, it is still objective c underneath. So here is what to do to make sure you don’t type two lines and the whole sample program breaks:

  1. Use the Git commit so that you can always roll back. With the interactions between the storyboard and the code, you can easily get to the point where the application just crashs.
  2. After every line do a run so you can see the errors. The system is good at catching syntax errors, but terrible when you are trying to use the user interface and the messages are really obscure. So Cmd-R is your friend!
  3. There is never enough screen space on a laptop, so I like to run everything full screen and then use the three finger swipe to move from tutorial to Xcode to simulator.

Related Posts

© All Right Reserved