How To Make An iOS App Run On Windows 8

Porting To Win8

If you know how to create an iPhone app, you're half way to building one for Windows 8. According to developer and consultant Aaron Hillegass, apps now offered through Apple's App Store don't have far to go before they can also reach the shelves of Microsoft's Windows 8 Store. "As soon as you have a successful iOS app, much of the work is done," said Hillegass, who's been programming since age 10 and got his first programming job at 19. "There are parallels between the two platforms and some things can be reused. You're not starting from zero."

A code re-write here, an API map there and in no time your apps should be riding on the Metro.

iOS Porting Makes Sense (And Dollars)

Why should you care? For one thing, Microsoft's revenue share is larger for successful apps than Apple's. After the first $25K, the revenue split for Windows 8 apps switches to 80/20 from its starting point of 70/30 (same as Apple's, which is fixed). And with 700 million Windows 7 license holders out there, many of which in theory will upgrade to Win8 eventually, the potential audience is huge while the competition is relatively small, with only 10,000 Win8 apps currently being offered.

"Angry Birds came out about a year after iPhone SDK," said Hillegass, who characterizes the hugely popular app as mediocre. "It's an OK game; it's not incredible. But, they've created an incredible franchise that makes $60 million a year in profits." There's even a TV show. "With the Windows 8 platform, there's a huge opportunity to create a franchise," he said, calling it 2009 all over again. "There's a business case." What's more, Microsoft allows developers to offer free-to-try apps that time out if not purchased. Apple does not; apps have to cost at least $0.99. Still not sold on porting? Read on.

Win8 In The Enterprise

The benefits of running apps natively on Windows 8 really pick up if your customers happen to be in the enterprise. "One thing that's neat is to run the app on a virtual server in a data center and access it on a tablet for a mobile workforce. This is a huge step forward because it's hard to use an app with touch that wasn't designed to use touch," said Hillegass, referring to pre-Win8 apps. "Microsoft has given us a way to create touch-friendly apps that can run in the data center but be accessed from tablets in the field."

Of course, iPad also can access server-side or cloud-based apps using Citrix Receiver or similar remote control methods. But, such solutions still involve accessing non-touch apps from a touch device. "Tools like that don't make a lot of sense for the enterprise. Win 8 apps can run on a server and still be touch-friendly," he said. "When you write the app for touch, they are more natural to use with touch." Discover similarities between iOS and Win8 Metro next.

Win8-iOS Common Ground

Apps made for iPad, iPhone and iPod Touch are similar to those made for Windows 8 Runtime, formerly code-named Metro. Firstly, apps for either platform are designed from birth for touch, so most of the touch-related heavy lifting is already done. Both use simple, task-oriented apps with animation and direct manipulation. Code tweaks will tie gestures to Win8-specific functions. Metro apps can be written in C/C++, Visual Basic and even JavaScript. But, according to Hillegass, iOS's Objective C will tie more closely to C#. "C# is an unsurprising language," he said. Both have real garbage collection. As for XIB vs. XAML, "iOS developers use the GUI builder in Apple's Xcode to create XIB files." Win8's XAML is similar. "It's XML that describes how objects will be created, but it's different in that it follows a cascading style sheets idea," which simplifies design changes. "For example, you can create a warning style with big red letters and use it anywhere in the app. It makes it easier to keep the UI consistent." Apps on both sides can parse XML, communicate with networks and consume the same Web services. Some important differences are covered next.


Shared APIs

The chart shows all of the APIs of the Windows 8 Runtime. Blue boxes are those for which there is not an analogous API for iOS. As iOS developers surely know, Apple platforms lack NFC, "Live Tiles," direct links to SMS and other things. When in doubt about how iOS APIs map to those of Win8, Hillegass refers developers to an online map of iOS-to-WinRT functions.

Also significant, C# is more strongly typed than Objective C. "Being loosely typed lets you do some powerful things with very few lines of code," said Hillegass. "For example, creating an object from a file, [as with] a persistence layer, tends to be elegant." Having iOS core data services simplifies object storage in SQL. Implementing persistence on the Windows side requires lots of extra code. With weakly typed languages, there's less error checking by the compiler. "On iOS, you have to be more diligent about testing. Because [C#] is strongly typed, the compiler can catch more errors at compile time, which creates less buggy code and lets you find your bugs more quickly," he said.


Though both run on finger-flicks, iPad and Metro are pretty far apart in terms of user experience. iPad users might not be immediately comfortable on the Surface version of your iOS app without some re-education. "Apple developed that pinch-to-zoom and showed us commercials until we got it," said Hillegass, who once worked for Apple and now builds apps for both sides. There's a similar pinch-to-zoom function on Win8, but in some instances, it changes modes and presents new ways to consume.

"Microsoft has worked hard to optimize the experience for tablet users, who usually consume, not create," said Hillegass, adding that Win8 real estate is maximized for content. "You want to use all the pixels for content, not for chrome," so commands are hidden until there's a swipe. Swiping in from top and bottom invokes app-specific functionality; left and right swipes switch apps or bring up the Charm bar. To be clear, all client-side Objective C code has to be re-written for Win8.

'Skeuomorphic' Vs. 'Digitally Authentic'

Then there are the things that just won't translate, and one of them is design. While Apple has encouraged developers to make apps look skeuomorphic (like things in the real world), Microsoft wants Win8 apps to look "authentically digital." Each has built its design tools accordingly. With Microsoft, "there's more emphasis on having type to describe things instead of using icons, and there are not as many reflections or shadows," Hillegass said, who correctly points out that it's fairly useless to use an icon of a 1990s-era floppy disk to represent the Save function. "It's easier to have a 'Save' button, but you'll have to localize it."

On the Apple side, a book shelf will look like it's made of oiled mahogany, and "a notepad looks like a notepad," he said. Also, Windows 8 offers no version of Bonjour, and Microsoft doesn't allow Windows 8 Store apps to use OpenGL; only DirectX is permitted. Hillegass, who founded training and development consultancy Big Nerd Ranch, has written numerous books on Apple programming, including the seminal Cocoa Programming for Mac OS X.