Bringing your iOS app to Windows

What is the iOS bridge

The Windows Bridge for iOS (previously known as Project Islandwood, or WinObjC) is an OpenSouce project started and maintained by Microsoft primarily and by the community that allows developers to enable their existing iOS apps written in Objective-C to run on Windows 10 as Universal Windows Platform apps. What’s more, you can enhance those apps with UWP specific features like Live Tiles, Cortana and others.

How does it work

There are 3 main components that make the bridge:

Compiler

A custom clang compiler was written for this project to support compile Objective-C language to Windows bytecode.

Compatibility Libraries

To ensure that your apps can compile without any code changes, all of the APIs had to be written to conform to the Apple API definition but using the underlaying Windows libraries. I.E Imagine the CCLocationManager class, implemented using the Geolocator API.
Additionally, all the Windows API definitions have been described as headers from the Windows core winmd files to be made accessible to the Objective-C language.

Tools

There are a number of differences in the way an Xcode project is structured vs a Visual Studio project. The vsimporter, tool will generate the solution files and convert any assets to match the requirements for a Windows App, while other tools will compile the Storyboards and Xibs.
Last but not least, the Visual Studio syntax highlight plugin enables nice syntax highlighting for Objective-C in Visual Studio

Converting your first app

The way I see it there are 3 steps in porting an iOS app with the Windows Bridge for iOS

Convert

In the conversion step we are transforming our Xcode project into a Visual Studio solution file that we can open up with Visual Studio. This is relatively easy, and seldom creates any issues. Open a command prompt in the folder hosting your Xcode project and run the vsimporter.exe file from the WinObjC bin folder.
What you’ll get is a new folder that contains the generated UWP project and a Visual Studio Solution file that you can open up.

Compile

With the first step out of the way, we can now open the solution in Visual Studio and make sure we can actually compile. This step is a bit trickier than before and you’ll often need to make minor adjustments to ensure the solution compiles.
If there are API’s that were not bridged you will get compilation errors and need to find workarounds for those portion of the code (a lot of the APIs have been stubbed out, so they won’t give compilation errors, but there are still some missing). Also due to platform differences some structs or enums might be different and you’ll need to fix those (i.e. mach_timebase_info_data_t missing in Win32 use mach_timebase_info_t instead)

Runtime

By far the most complex task, and probably where most of the time will be spent in a conversion project is to ensure that at runtime, the project works and behaves as expected.
All those missing APIs that have been stubbed out will start to cause problems now, and some differences in how APIs are implemented can crash your app.
It’s too broad of a subject to try and describe in great detail, but the one thing that is worth mentioning at this point is that every time you encounter a runtime problem, your first instinct should be to find the root cause and see if this is a problem with your code or maybe a more general issue with the SDK itself, and if it’s generic enough, open an issue of the project’s page or better yet, open the issue, and try and fix it and open a pull request so that everyone else can benefit from it.

Enhance your app

If that wasn’t enough, after you have finished converting your app and everything works great on Windows, you can go a step further and start enhancing the app with Windows specific features like Cortana, Live-Tiles, Notifications, etc. You can do that with using Objective-C code since all the Windows APIs have been exposed and accessible from your ObjC code.

Help improving the bridge

Contributions to the project are always welcome. As I mentioned above, whenever possible, try and update the SDK rather to change your code if something does not look right. If you’re having an issue and the code works properly on iOS, that might be a good thing to update in the SDK for future conversions to just work.
Make sure you read the contribution guidelines.

Other resources

The main project page can be found on GitHub where there are links to great additional resources.

Check out the BUILD 2016 session - Getting started with the Windows Bridge for iOS

Lastly the Dev Center Bridge for iOS page.

Share Comments

Links of the week (May30-Jun5)

Some of this weeks most interesting articles and news:

HoloLens Software Update

Opening Windows Holographic

HyperDev by Fog Creek

Designing for Virtual Reality

Share Comments

Xbox One Deploy Error

As I was trying to deploy one of my apps to the Xbox One, I ran into a strange error that ate a lot of my time to fix.
I don’t think you’ll be getting in this touble if you start from scratch but considering a lot of the new apps on Xbox will be existing apps, this might apply

The Error

1
2
3
4
DEP0700 : Registration of the app failed. 
Deployment Register operation with target volume C: on Package xxx_xxx_x86__wr8y21pj9dftj
from: (AppxManifest.xml) failed with error 0x80073CFD.
See http://go.microsoft.com/fwlink/?LinkId=235160 for help diagnosing app deployment issues. (0x80073cfd)

Fixes

  • Make sure package.appxanifest TargetDeviceFamily includes Windows.Xbox or Windows.Universal.

    1
    <TargetDeviceFamily Name="Windows.Xbox" MinVersion="10.0.0.0" MaxVersionTested="10.0.10586.0" />
    1
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.10586.0" />
  • Fix Visual Assets

    • Scale 200 required. This is the default scale for Xbox and you might not have all your assets if you only targeted small factor screens before.
  • Package Name
    • Some package names would fail to deploy. Could not find a clear pattern but mostly when a ‘.’ is involved it tends to fail. If nothing else works, consider playing with the package name.
Share Comments

Xbox One Developer

As I’ve mentioned in my Build 2016 overview post, this year Microsoft announced they are finally opening the Xbox One for developers to deploy and debug their apps.
So I did a quick test and tried to deploy one of my apps on the Xbox as a quick experiment.

To get started you can read all about it on the official site but here is a quick summary of the most important things I found

  1. Read the fine print before you activate developer mode. Some of the limitations are pretty rough so make sure you are aware of what you’re getting into: some games might not work anymore, you might need to reset your console to leave the developer mode and streaming to a Win 10 machine is not going to work anymore.
  2. You do need a developer account to enable Developer Mode on your console. Within your developer account you can only activate 3 consoles. Once activated, multiple developers can pair to the console and deploy from their Visual Studio
  3. When deploying from Visual Studio, ensure that the authentication mode is set to Universal. The error you get if the mode is incorrect is not the most obvious error so pay attention beforehand.
  4. If by any chance your app is a WinJS app rather than a XAML/C# app, you will need to make some modifications to make it work out of the box. Check out the great TVHelpers library.

I’m really excited at the new possibilities that the Xbox opens and I am looking forward to publishing my first Xbox compatible app soon.

Share Comments

HoloToolkit Framerate display

I’ve been working with the HoloLens for about 6 weeks now (yes, I’ve been one of the lucky Wave 1-Day 1 HoloLensers) and even though I haven’t written anything yet, there’s a lot of stuff I learned about it and I will try to start and put in on “paper” in the following weeks.

Performance Performance Performance

One of the key things in delivering a truly amazing HoloLens experience is performance. Top priority from start to end of the project is to have the application running at 60fps ()
I am not going to write here about the techniques on how to achieve that - you can find all about it on the excellent HoloLens documentation site here and here, but I will present some pointers on how to measure that framerate as easily as possible.

Read More

Share Comments

Tackling the MS 70-355 exam

As my current MCSD - Store Apps (Win 8.1) certification will expire at the end of August I started looking at the next step MCSD - Universal Windows Platform certification.
I quickly passed the first one MS 70-354 but then I got stuck at the second and more difficult one - MS 70-355.

Not only the syllabus for the exam is way more extensive, but the lack of an official study guide makes it hard to study for it.

So I’ve attempted to dissect the skills measured section, broke it down 3 level deep down to the base topic for each chapter, and provide links to documentation for each section (where’ there’s a missing link, I did not find any relevant official documentation on that particular topic. I will update the post as I find them)

Read More

Share Comments

Build 2016 overview

Even though it’s been a month since BUILD ended, the announcements made and their importance still resonates today.

Mobile First Cloud First

First takeaway comes from the first moments of the keynote. It’s defining Microsoft’s strategy with a somewhat cliché motto, but what makes it interesting is the explanation that Satya Nadella gave when talking about it.
In Microsoft’s view, mobile does not represent what we all think it does, it’s not referring to a device or even a category of devices. What it represents is the mobility of the users. It represents the freedom of being anywhere, using device at any time and have all your knowledge, context and information with you. And to make all of this possible you need the cloud which has everything you need and it’s accessible from anywhere you need it. In this light I believe that Microsoft is really close to achieving this vision.

Read More

Share Comments

BlogDevOps

As I was mentioning the inaugural blog post, I was looking to build a simple but elegant solution to manage my blog, and as I went for the static site generator route, I was left with no “administration” panel to write and publish posts.

While researching my options, I noticed a lot of people were using GitHub to host their sources, and deploying either to GitHub pages or to other hosts via Git hooks. But I wanted to use the infrastructure I already had in place using Visual Studio Team Services to host the code and Azure Websites for hosting.

The process - how does a static site work?

First of all, I had to understand how Hexo works (and pretty much any static site generator for that matter). This wasn’t very hard, you just need to read the readme file of the tool. I’ll lay it out in a few words. First you need to install the tool, usually using npm. Once you have it, you can initialize your blog in a new folder - I’m not going to go into any more details about this, maybe another post. Suffice to say, this folder is now your “source” for the blog. Since the tool has quite a few dependencies, you need to run npm install to ensure they all get deployed in your folder as well. Once you have that, you run a command to generate your site - same as you would compile your sources in any other language. The result of this compilation is a folder that is essentially your entire site - a self-contained website consisting of just a bunch of HTML, CSS, JS and images. The idea is, you take this folders and publish it anywhere and you’re done with it.

The goal

So my goal for the blog deployment was to be able to host my code in Visual Studio Team Sarvices in a Git repository and every time I write something, commit the article and via some magic in the next couple of minutes my Azure Website would show the post. I could commit a new markdown file in the repository from anywhere or any device and it I would get a new post on my blog. No need to worry about compilation, deployment, or anything

Read More

Share Comments

Hexo image hacking

As I just started blogging on the hexo platform I quickly stumbled upon a behavior that was not what I expected.

I wanted to insert an image that links to a different site, but because of the fancybox implementation whenever you clicked the image, it would open the image rather than opening the link as I wanted.

For example, I want to show my StackOverflow flair image and point the link at the profile page:

1. The most basic thing you would try is:

1
[http://stackexchange.com/users/flair/17621.png](http://stackexchange.com/users/17621)

This will render like this:

https://stackexchange.com/users/flair/17621.png

Obviously not what you’d expect. All right, maybe what you’d expect, but certainly not what we want.

2. Trying to fix our initial mistake, try and render the image in the tag

1
[![Alex Drenea's Stack Exchange profile](http://stackexchange.com/users/flair/17621.png)](http://stackexchange.com/users/17621)

Rendering like:

Alex Drenea's Stack Exchange profile

This is close to what we want, but not exactly there. If you click on the image, it just open the fancybox for that image, but I want clicking the image to take me to the destination website instead. I don’t like the caption under the image in this case even though it points to the right link. But I want the image to go to the link. I also don’t like the center alignment.

Read More

Share Comments

Making it happen

The beginning of a new era

It’s been a while since I felt the need for a blog to put down my various thoughts and finds. At the same time, I feel more and more that it’s time to start giving back to the community. Combined with the fact that I’ve been doing some pretty interesting new things at work lately I thought there’s no excuse in putting it off any longer and set up a goal to get it done last weekend.

As you can see in the about page, I am not really an web guy so I knew going in that this will not be easy. But hopefully I made it work and I will be more than happy to hear your feedback and learn from you guys how to make it better.

Read More

Share Comments