Review: Xamarin 2.0 works mobile development magic

Impressive Xamarin SDK brings native iPhone and Android development to C# programmers, Visual Studio

Page 2 of 4

iOS app development: It's complicated
Although Xamarin lets you use your Windows PC for iOS development, that doesn't mean you don't need a Mac. For a number of reasons, Xamarin still requires Apple's iOS SDK tools to complete the code generation. For example, the Xcode simulator is required for code debugging, and the app's interface must be designed using Xcode's layout and storyboard editor, Interface Builder (IB). Finally, to distribute apps in the App Store you must use Xcode's code-signing mechanism.

How is it possible to use Visual Studio to write and debug iOS apps? Xamarin performs a clever sleight of hand that sets up the Mac as a back-end build server to Visual Studio. Installing Xamarin on the Mac places a remote build server on the computer. This build server uses Apple's Bonjour service discovery protocol so that Windows systems can find it on the network and establish remote sessions with it. An inexpensive Mac Mini can be used as a shared network resource for multiple Windows developers.

When you execute a build with Visual Studio, the remote session has the build server issue the appropriate command lines to the Xcode build tools. (This works because the Xcode IDE itself is simply a GUI layered over command-line tools.) After the build completes, the iOS simulator on the Mac starts and remote commands from Visual Studio operate the simulator through the Xcode debugger. Or the Xcode debugger can download the code onto an iOS device, and you can debug it there through Visual Studio.

The other aspect to iOS app development is whether to IB or not to IB. The UI of an iOS app can be constructed two ways: either through program code or by using Xcode's visual editor. IB lets you lay out the app's interface by pointing, clicking, and dragging UI elements. These UI elements are actually Cocoa Touch framework objects in a serialized format. That is, you manipulate the UI objects themselves in IB. This ability to edit Cocoa Touch objects is not easily duplicated on the PC. Therefore, you either have to use IB on the Mac to design the app's UI or write the UI entirely in code to implement it. In the latter case, you can use a utility like PaintCode, which lets you design the UI visually; it then generates the appropriate Objective-C or C# code.

Constructing the UI for an Android app can be accomplished with Windows tools, because Android uses XML to store the layout. Xamarin Studio has a graphical layout editor similar to IB that lets you construct the Android app's UI visually. Xamarin also provides an add-in that implements this graphical editor in Visual Studio.

Review: Xamarin 2.0 works mobile development magic
Using Xamarin Studio to run a C# app in the iOS simulator. A breakpoint has been set in a platform-specific UI file that manages the native implementation of a log-in screen.
| 1 2 3 4 Page 2
From CIO: 8 Free Online Courses to Grow Your Tech Skills
View Comments
Join the discussion
Be the first to comment on this article. Our Commenting Policies