Visual Studio Tools for Tizen

Tizen is Linux-based open-source platform for mobile phones and TV-s. Earlier this year Samsung announced Tizen development tools for Visual Studio and now it is time to try out how things work. Although the tooling is still in preview and there is no stable version, it still possible to start playing with Tizen development. This blog post gives overview of my first experiences with Xamarin Forms and Tizen development.

NB! My experiment started actually by trying out Visual Studio Tools for Tizen but as Xamarin Forms supports also other platforms like Android, iOS and UWP, I went on with all of these (except iOS because I don’t have any option to run XCode server). So, sample application doesn’t contain just Tizen project but also Android, iOS and UWP.

Sample application. My Xamarin Forms sample application with Tizen support can be found from my GitHub repository MyMobileApp.

Tizen templates

There are three project templates available for Tizen:

  • Blank App (Tizen Xamarin.Forms Portable)
  • Blank App (Tizen Xamarin.Forms Single)
  • Class Library (Tizen)

Template for portable version creates solution with Portable Class Library (PCL) where shared code and views are held. Single means that there is one project that contains all artifacts. As I found out during experimenting then shared libraries are not yet supported.

When creating solution with PCL there is project wizard where we can configure our Tizen solution.

Tizen Project Wizard

Important thing is to understand profile options:

  • Mobile – create project for mobile application,
  • TV – create project for TV application,
  • Common – create one appilcation project that runs on TV and Phone.

My solution uses separate library as I share code and views with other mobile platforms.

Tizen applications

Tizen projectTizen applications simple structure. The following folders are created by default:

  • lib – folder for additional libraries used by Tizen application,
  • res – resource files delivered with application,
  • shared – folders shared with other applications and operating system,
  • shared/res – resources shared with other applications.

There can be more folders like described in document Tizen File System Directory Hierarchy.

tizen-manifest.xml is manifest file similar to what other mobile platforms have – definitions for application and it’s capabilities. With Visual Studio tools comes also nice looking editor for Tizen manifest files.

project.json is also present and this is where dependencies, frameworks support, build settings and runtimes are described. I am not sure if this file will be needed in future as with .NET Core projects Microsoft is moving back to .csproj files.

As Tizen uses Xamarin Forms then start-up code for application is short and primitive.

class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication
{
    protected override void OnCreate()
    {
        base.OnCreate();
           
        LoadApplication(new App());
    }

    static void Main(string[] args)
    {
        var app = new Program();
        global::Xamarin.Forms.Platform.Tizen.Forms.Init(app);
        app.Run(args);
    }
}

Here application is initialized and then Xamarin Forms application is loaded from PCL project.

Tizen emulators

Tizen tools come with emulators for mobile phones and TV. There is nice and simple emulators management application that is installed with Tizen tools. This is the place where emulators are created and managed.

Tizen Emulator Manager

NB! There are some requirements for using Tizen emulators. Your machine must support hardware virtualization and Hyper-V must be disabled. You can find more information from document Installing Visual Studio Tools for Tizen.

I wasn’t able to get my application running in mobile emulator due to emulator’s network issues. Emulator for TV works well with same network settings but network connections are very slow. It takes around half a minute to load small RSS-feed with world news by Reuters.

Here is the screenshot of my sample application running on Tizen TV-emulator.

Tizen TV app

Although the emulator seems primitive it has many settings available like described in document Emulator Control Panel.

Supporting Tizen projects with other Xamarin Forms projects

Although Xamarin Forms projects for Android, iOS and UWP support shared libraries, it doesn’t hold true for Tizen projects. Today Tizen wants PCL or .NET Standard project. Good thing is that other projects support .NET Standard too.

If you started with PCL project then delete it and create new .NET Standard project using Visual Studio. Move all your files from PCL to there. Then unload .NET Standard project and edit it with Visual Studio. Make sure that target framework is netstandard1.4 and library also supports PCL:

<PropertyGroup>
  <TargetFramework>netstandard1.4</TargetFramework>
  <PackageTargetFallback>$(PackageTargetFallback);portable-win+net45+wp8+win81+wpa8</PackageTargetFallback>
</PropertyGroup>

Save project file and reload it.

Maybe there is some better way to do it but this is what started working for me.

Troubleshooting

As Xamarin Forms and Tizen tools both are new and kind of raw then don’t be surprised when running to different issues.

  • Be careful when dealing with NuGet packages. Some packages come with settings saved to project files and on removal they don’t clean up their modifications. It’s easy to cause “package hell” this way. If you are running out from ideas then check project files in edit mode and see if there are no traces left by removed packages.
  • Debugging can be challenging as sometimes code seems not to hit breakpoints. It usually means that there is some longer network delay if your code connects to internet for data.
  • It’s possible you don’t get much information about code when breakpoint is hit in shared library. Only some properties of objects are shown and some variables are not reachable through locals and immediate window. If you don’t find any good way for debugging then just move the code to UWP (or some other) project and debug it there. This way I was able to debug out dome nasty code errors that appear only when code is running.
  • Sometimes exceptions are not informative. You see simple message stating there is error but no details are provided. It’s possible in some cases to get more information when you click Continue and then check outpout in debug window.

Wrapping up

Although Tizen tools are in preview they are already pretty well usable with Xamarin Forms. There are some annoying issues and things that doesn’t work well but still it’s possible to start trying Tizen tools out with real applications. Available tools look promising to me and it’s good to see that Tizen will be platform where Xamarin developers can make their applications available in the near future.

Gunnar Peipman

Gunnar Peipman is ASP.NET, Azure and SharePoint fan, Estonian Microsoft user group leader, blogger, conference speaker, teacher, and tech maniac. Since 2008 he is Microsoft MVP specialized on ASP.NET.

    Leave a Reply

    Your email address will not be published. Required fields are marked *