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 (() => this.UpdateScore ()), jump, new CCCallFunc(() => 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

Migrating from Parallels Desktop 10 to VMware Fusion 7: Android SDK broken, WP Emulator not working

Recently I switched my Parallels Desktop 10 VM setup to VMware’s Fusion 7. I had various (random) problems with Parallels Desktop 10 and decided to give Fusion a try. The result: Fusion 7 does not support all the fancy DirectX 10 support, but for a virtual Windows 8.1 development machine on my Mac, it is the better choice.

Migrating over was easy: I simply imported the PD10 virtual hard disk. In 30 minutes it was converted over into Fusion’s format and started up just fine. Everything worked pretty well but then I found a view things I had to adjust.

Continue reading