But I don’t need the complete Github repo!

We all love example code and there’s plenty of code hosted on Github. Xamarin for instance has a large repository at https://github.com/xamarin/mobile-samples/. And of course Github makes it very easy to download such a repo by just hitting the big green button:

Button to download a Github repo

Download a repo

But right now I’m on the train, tethered to my iPhone and I just don’t feel like downloading the entire repo, all I want is the CoinTime game app!

Here’s how I solve this problem: instead of using Git, I use Subversion (SVN) which is supported by Github, too. Just open Terminal and run the following command:

svn checkout <URL>

where <URL> will be replaced with the actual project to clone.

In my example, CoinTime’s URL is:


To use SVN, we simply replace “tree/master” with “trunk” and the command becomes:

svn checkout https://github.com/xamarin/mobile-samples/trunk/CoinTime

And we have a subfolder named “CoinTime” with exactly that one project in it!

Using OAuth2 with Microsoft OneDrive and Xamarin.Auth

Last week I had an interesting question about Xamarin.Auth, a library that allows Xamarin apps to authenticate users via standard authentication mechanisms (OAuth2), and store user credentials.

You can see how I wrote the word “standard” in bold because as long as some OAuth2 service follows the standards, Xamarin.Auth should support it. So my answer to whether Xamarin.Auth will work with OneDrive’s OAuth mechanisms was clearly “of course, it does”.

I was wrong.

Continue reading

iOS Background Transfer – what about uploads?

Downloading files in the background is easy with iOS since the introduction of the NSUrlSession background transfer APIs. There are plenty of examples and instructions around for ObjectiveC but also for Xamarin.iOS.

Documentation about the APIs is pretty exhaustive over at Apple and covers everything you have to know to get started.

And then, you start asking yourself: what about uploading data? And it turns out there aren’t so many working examples and in fact it can be quite tricky to get things up and running. I was in contact with Apple support and they helped me to find answers to many of my questions. This blog post is trying to conserve to essence of my mail communication as it can help others who are challenged with implementing background upload.

Continue reading

Launching an Android Activity of another APK

We have discussed Android and its Activity system today. It is quite hard to grasp for an iOS guy like me; it feels…special.

I certainly know how to start an activity within my own app and I understand the difference of an explicit Intent vs an implicit one. But there are a couple of questions I couldn’t find answers to, particularly not something that would show how things work with Xamarin.Android.

So I created a small test app to answer the following questions:

  1. How can another app be launched directly?
  2. How can an Activity of another APK be started via an explicit Intent?
  3. How to implicitly start an Activity of another APK?

Continue reading

Xamarin.iOS, the garbage collector and me

A lot has been written about the Garbage Collector and Xamarin.iOS. Lately, I’ve been hit by some surprises and I want to share my findings. Let me say that there is not a single bug involved! All the issues I describe are either documented or show standard behavior of the .NET runtime. The fact that Xamarin.iOS lives on top of a reference counted world makes things a bit more difficult.

Many thanks to Rolf Bjarne Kvinge for his patience, Marek Safar for sharing the secrets of Mono compiler with me, Rodrigo Moya for helping me with the Xamarin Profiler, James Clancey for his drawings about native reference cycles🙂 and Chris van Wyk for supporting me in these moments of “good god, this cannot be!”

Continue reading

Adding async/await to CocosSharp actions

UPDATE: The CocosSharp team has decided to integrate my ideas directly into their source!🙂

Are you a C# programmer? Using Xamarin? Are you interested in making great games that run…

  • cross platform,
  • from one code base
  • and are powered by Cocos2D and XNA?

If yes, then you should check out CocosSharp!

I used Cocos2D in the past (the “good” old days of ObjectiveC…) and liked it a lot. Seeing all this translated to C# just freaks me out!🙂

However there has been one thing that bugged me: chaining actions and running actions simultaneously.

Say, you want your character to scale, then increase some score counter, afterwards make the character jump and then reset the animation phase to the default frame. You would use something like:

var scale = new CCScaleBy (1f, 1.5f);
var jump = new CCJumpBy (1f, new CCPoint (100, 100), 50, 2);

this.RunActions (scale, new CCCallFunc (() =&gt; this.UpdateScore ()), jump, new CCCallFunc(() =&gt; this.SpriteFrame = this.defaultFrame));

Works, but with the power of C# we can do better!

Continue reading

Fix too small iOS Simulator on Retina Macs

Recently I received my MacBook Pro. It’s the 13″ model with Retina Display. I run it in the 1680×1050 HiDPI mode to get more content on the screen (I use the nice little tool called QuickRes to conveniently switch resolutions).

Before I had the MacBook Pro I was working on a MacBook Air with significantly lower resolution and when testing my iOS apps in the Simulator, I had to scale the Simulator down to fit on my screen. This can easily be done by pressing CMD+1 (100%), CMD+2 (75%) and CMD+3 (50%) or via the Window -> Scale options.

Now with the MacBook Pro it is the other way round: an iPhone 5 is simply too small even at 100%. See the screenshot below.

Continue reading