iOS for C# Developer - part 4: Xcode

 Date: September 19, 2014

This post is part of the series: iOS for C# Developer. Previous parts:

C# developers works with Visual Studio. Recently, some are trying to switch to SublimeText. However, I will assume that you, as C# Developer are familiar with VS. To write iOS applications, you need Xcode. I haven't heard about nobody who created an working app in a different editor (more advanced than Hello World).

In this post I would like to provide a few tips that will help you to get started and be productive.

The first thing that is worth to mention is the fact that Xcode is free. You cannot test you apps on the iPhone or iPad before you pay $99 though. You need to be satisfied with simulator.

Key shortcuts

For the beginning, remember three:

  • ⇧ + ⌘ + O - quick open (equivalent to CTRL+, in VS2013 or CTRL+T in ReSharper)
  • ⌥ + click - jump to documentation (when clicked on class/interface)
  • ⌘ + L - jump to specified line of code

This three will definitely help you to get productive at the beginning. You can find more in this cheat-sheet.

Debugging

In order to debug application in VS, you have to run it in debug mode. In Xcode, when you run the app on emulator it is always in debug mode. Thus, you just need to set the break-point (by mouse click on the line number, like in VS, or by ⌘ + \ shortcut) and run the app (⌘ + R). Once break-point is reached you can step over (F6), step into (F7) or step out (F8).

Very useful during debugging is dumping objects into console with NSLog function:

NSLog(jsonString);

This outputs, e.g., JSON string to the console, which allows you to inspect it.

To get more flavor of debugging, check Apple documentation and Brian Moakley's blog post.

Playgrounds

The latest version of Xcode (v6), which introduce support for Swift language, adds also very handy feature: Playgrounds. It allows you write and test simple Swift programs, without using iOS emulator. Playgrounds are useful especially, when you are testing some complex logic. They are very powerful. You can use them even to test drawing (still without running iOS emulator). To see it in action, check this demo.

Summary

Xcode is very nice IDE. Works very smooth, and breaks very rarely. I wish there was more code snippets (like it is in Visual Studio, especially with ReSharper or WebEssentials). Xcode could also adapt rich debugging experience from VS (e.g., inspecting object variable after moving mouse pointer in top of them). I find it hard to work with this IDE on small screen (like MacBook display). To get comfortable, I need at least 22-24". But that is just my opinion. What do you think?

 Tags:  programming

Previous
⏪ iOS for C# Developer - part 3: multithreading

Next
Azure tutorials to get started ⏩