Many months ago Microsoft announced their intention to enable iOS developers to use their Objective-C code inside a Windows 10 application using a tool dubbed Project Islandwood. News of the tool's progress was quiet for a few months, but back in August, Microsoft released the opensource project to GitHub as the Windows Bridge for iOS. I was curious to try out this tool to see how well it worked, what the projects looked like, and experience the novelty of looking at Objective-C code in Visual Studio. I spent some time playing with it, here are my experiences working with it.
There are a few requirements that you need to meet before you can test out the bridge. On the PC side, you'll need:
Once all of those requirements are met, you can start importing Xcode projects into Visual Studio.
Once I had installed everything, I tried to migrate a few different projects that I had previously created in Xcode. The steps for this process were as follows:
First, I tried simply converting one of the Xuni 101 projects to see if I had any luck with the importer. Perhaps not surprisingly, since Xuni is separate framework, this didn't work. The case for most third-party frameworks indicates that they'd each need their own specific conversion to work with Project Islandwood. Many of Apple's built-in frameworks (such as UIKit) have already been provided by Microsoft, so importing a project that only relies on these already-converted frameworks should work. To this end, I imported my recent custom checkbox example which is only dependent on UIKit. I had some more luck getting a primitive version of this to run.
Debugging and editing the Objective-C files was easy in Visual Studio (if a little strange-feeling), and I was able to set breakpoints and view the call stack. The project structure was still familiar enough that I was able to navigate inside the project without too much issue. Microsoft also allows you to use its XAML controls in Objective-C provided you import "UWP/WindowsUIXamlControls.h" in your viewController. I tried adding a slider control to my viewController, and I found it to be a relatively painless process. Essentially you're able to create the XAML control in Objective-C (WXCSlider for my example), configure and style it (including creating a callback for any events you might want to capture), create a UIView where you want your control to be placed, and then call the setNativeElement method to add your XAML control to your UIView.
WXCSlider *slider = [WXCSlider create];
slider.requestedTheme = WXApplicationThemeDark;
slider.minimum = 0.0;
slider.maximum = 100.0;
slider.value = 25.0;
slider.smallChange = 5.0;
slider.largeChange = 20.0;
[slider addValueChangedEvent:^ (RTObject \*sender, WUXCPRangeBaseValueChangedEventArgs \* e){
sliderLabel.text = [NSString stringWithFormat:@"Slider value %.0f", e.newValue];
}];
UIView *sliderView = [[UIView alloc]initWithFrame:CGRectMake(10, 200, 250, 50)];
[sliderView setNativeElement:slider];
The tool does seem somewhat limited at the moment, and looks most useful for converting projects that are relatively simple and don't have many dependencies on other frameworks. Also, there's no support for converting Swift code at the moment which may put a damper on the tool for many.
Microsoft promises to continue to add new features to the Windows Bridge for iOS so that it's more compatible and feature complete. It does present an interesting opportunity for developers to quickly bring their iOS applications to UWP, but only time will tell how popular the tool becomes. As for Xuni, it's more likely that we'll explore a different path using Xamarin to create UWP applications in the future. It's an impressive piece of technology if nothing else, and it will be interesting to see how it develops.