Getting started with Project Islandwood

Update: The Project Islandwood repo on GitHub (aka "Windows Bridge for iOS") has been updated to support iOS storyboards. This greatly simplifies the little tutorial in this blog post. Simply create a single view app, add some buttons and labels, and save it. Then use the vsimporter.exe tool to convert the project (storyboard and all!) into a Visual Studio solution. No need to strip out the storyboards and add ViewControllers! I told you they were making great progress :-) See this blog post on how I ported an openGL game using a Virtual Machine on my Mac!

 

If you are an iOS developer, the Windows ecosystem can appear a strange and frightening place. Writing an app for Windows requires an investment in all kinds of new things: new tools (Visual Studio), new languages (C#), new APIs and Controls (Win32, XAML), new graphics engines (DirectX) and before you know it, life seems too short and wouldn't another Flappy Birds clone be more fun anyway?

 Fear not, brave adventurer, for Project Islandwood is here.

 

 There are many different ways to make projects work in a cross-platform way. You could, for example, create some type of mimicking run-time, and run the same binary file on that. That's not easy, as although your app might still look like a native app, it would be running on a non-IOS platform and that of cognitive dissonance can be unsettling. And you don't get to take advantage of any unique Windows features. And you have to worry about code-signing, updates, subtle platform differences and so and so forth.

 Alternatively, you could write some kind of intermediate tool based on, say, JavaScript and HTML5, and provide run-time wrappers for different platforms. That would work, but JavaScript is not everyone's favorite programming language, and you need to keep the wrappers updated for every platform. And you've immediately gone to the lowest common denominator of every platform (a web browser), thus missing out on potentially cool features.

 Or, and this is kind of mind-blowing, you could do what the Project Islandwood team have done, and create a conversion tool that loads an Xcode project (complete with assets and Objective-C files), and changes it into a Visual Studio solution that can be edited, built and deployed to Windows as a proper Windows app. More amazingly, this tool doesn't try to convert your source code to C# or JavaScript: the app is in Objective-C and it WILL ALWAYS BE IN OBJECTIVE-C. Yes, you can edit and build and deploy your code from Visual Studio to Windows. Yes, Windows is compiling Objective-C.

 Project Islandwood is under active development (see this blog posting) and there is still much to be done, but you might be surprised just how much works today. Here's a walkthrough that will create an Xcode project (in Xcode 7.1), convert it, and run the same app on a PC Windows 10. The tools to do this are all free, by the way. All you need is a Windows PC (or virtual PC running on Parallels, Fusion, Bootcamp etc.). In fact, the Islandwood team have promised that they'll have Virtual Machine images available to download to simplify this process even more.

 To set some expectations, I wouldn't think of this as a way to continue major development on the PC side - there is no good way to edit the ViewControllers once they have been converted into XML for example -  think of it more as a "Ok, I need to get this Windows version of this project kicked off, and this tool will get the grunt work done for me". 

You will need.. 

 

If you want to try out Project Islandwood for yourself by following this little tutorials, you'll need these tools:

*  A Mac running the current version of Xcode.

* A PC (or a virtual PC) running Windows 10.

* A copy of Visual Studio 2015, including the Windows 10 SDK (the Community edition of Visual Studio is fine - and it's free)

* A copy of the project Islandwood tools, downloaded from GitHub. 

I recommend that you install Visual Studio and test it first. If you can create and compile an empty Blank App (Universal Windows) app, then you are good to go.

 

 Creating a suitable Xcode Project

Here's how to create a Windows app from an iOS app. It's hard to believe, but the trickiest part of this process is creating a suitable Xcode project. Why? Because the current version of Islandwood does not support storyboards, and as you know, storyboards are now such a fundamental way of writing iOS apps that Xcode doesn't even offer the option to create a new project without them. However, we can go back to the good old days of Xcode 5 and .XIB files by butchering an existing project. Here's how I did it.

1. Create a new Xcode project, based on an iOS Single View application.

2. Set the language to Objective-C. I select iPad as my target.

3. Delete the following files from your Xcode project:

* Main.Storyboard

* LaunchScreen.Storyboard

* ViewController.m

* ViewContoller.h

 

4. Open info.plist, and delete the following references:

* Launch screen interface file base name

* Main storyboard file base name

 

5. From File > New > File, create a new Cocoa Touch Class, of type UIViewController, and name it ViewController. Make sure to check the Also create XIB file option.

 

6. In the Project target settings, delete any value for MainInterface. It needs to be blank.

7. Edit the AppDelegate.h and .m files, changing them to:

 

 

 

This should be enough to get a blank app working in the Simulator. 

 You should now try adding a UILabel and some UIButton so our app actually does something (although it's probably still no Flappy Birds).

 

 Making a Visual Studio Solution 

Now that we have a working Xcode project, we can convert it to a Windows solution.

 

1. Copy the entire project folder over to your Windows PC (real or virtual).

2. Open a Command Prompt, and navigate to the folder containing your Xcode project.

3. Start the vsimporter.exe app (from inside WinObjC/bin folder you obtained from GitHub). 

For example, enter something like:

../../winobject/bin/vsimporter.exe 

4. Watch in amazement as the new Visual Studio project is created. 

It will be named <Xcode project name>-WinStore 10.sln

5. Double-click on the .sln file, to open Visual Studio and your new solution.

6. Once opened, right-click on project in the Solution Explorer view on the right, and select Set as Startup Project.

7. With Debug, Win32 and Local Machine set, click the build-and-run button (the green arrow).

8. Your app should now run as a Windows app!

 

 What's next?

 

The Project Islandwood folks have promised all sorts of improvements as the project evolves. At the moment, the number of iOS frameworks supported is limited, so only simple apps can be ported automatically. Storyboards are also an important omission. If you're using 3rd party graphics or physics engines that are mostly C++ / Objective-C you might be in luck, but I was blocked by a lack of SpriteKit and other frameworks from porting some of my more interesting apps.

 But, that said, work is progressing. The team is even looking for iOS devs to provide them some sample .IPA files so they can analyze them and help create a useful tool for provide a pre-conversion checklist. And the team would welcome your input via the GitHub site.

 

 

 

- John Kennedy, Content Developer.