Tim Sneed: Setting up Wormhole Sharp to Communicate with iOS Extensions

I am adding an Apple Watch app to my latest project and needed a way to communicate with the parent app on the phone. I looked at Wormhole for this type of communication, and I was happy to see that there is a port, appropriately named Wormhole Sharp. Wormhole and Wormhole Sharp use App Groups to create a way for apps to shared data via the iOS file system.

Download and build Wormhole Sharp from here and add a reference to both the parent and extension app projects.

Open the Entitlements.plist in the parent app project and select Enable App Groups. Add a new entry in the App Group section.
Do the same in the extension project and make sure to name the group the same

image of group

Apple requires naming groups by starting with ‘group’ and then using their common reverse naming style

image from apple dev site

After setting the group in both the extension, and the parent app, go and set the “Custom Entitlements” to the Entitlements.plist for both the parent and extension respectively. Do this by double clicking on the project in the solution pane.

image of entitlements

This is the most critical part, without this it will not work and you will spend a day trying to figure out what is going on.

That’s it.

Next we will learn about communicating between App Extensions and the Parent App using Wormhole Sharp. I spent way more time getting this configured to work than I did with setting up back and forth communication.


Nic Wise: Autolayout and auto-expanding UILabel

One thing I miss in iOS, which Android has, is auto expanding labels (and other views). Android has the wrap_content layout option, which works really well to flow a view.



iOS was lacking that – or so I thought. In the past, I’d had to use code to measure the size of a block of text, then set the frame and adjust other things.

var size = new NSString("Text here").StringSize(font, 9999, UILineBreakMode.CharacterWrap);
label.Frame = new CGRect(label.Frame.Origin, size);

Autolayout changes things a bit. It’s all declarative-y and designer-y, so I prefer to keep things like that inside the storyboard designer as much as possible. I recently learned how to do this, tho: the >= (or <=) constraint.

Storyboard Editor

In this case, I want the stop identifier (WW) to resize based on it’s content. It could be blank, or it could have one or 2 letters. I’m using the size of WW – about the maximum width – as the largest size, and allowing it to resize as needed. All the other constraints which are dependant on it flow from there.

The only constraint I need to manually adjust is the space between the WW and the following label (“7” in the image – “75m North West”), as I want to remove it – set it to zero – if the stop id is blank.

This works for vertical height too. Set it to be greater than or equal to the minimum height – usually one line of text, which is around 21 points – and set the number of lines to zero. The label will now take as much vertical space as needed.

This is not something which is obvious, at least it wasn’t to me, but it solves one of the big blockers I had with both Autolayout, and iOS in general – dynamic layout, especially of text.


Xamarin: Join Xamarin at Mobile Dev + Test in San Diego, CA

Join Xamarin at our first Mobile Dev + Test conference in San Diego, CA from April 14-16, 2015. Key members from the Xamarin team will be available to answer your questions, discuss your apps and projects, and show you what’s new in Xamarin Test Cloud. James Montemagno, Xamarin Developer Evangelist, will talk about mobile’s impact […]

The post Join Xamarin at Mobile Dev + Test in San Diego, CA appeared first on Xamarin Blog.


Xamarin: Beggin’ for a Beacon Xamarin Contest Winner!

Beacons, small pieces of Bluetooth-transmitting hardware, have simplified the ability to create context-aware apps for mobile devices. Given the powerful potential beacons have for impacting the world, we wanted to hear how the Xamarin community would use beacons to improve their lives in fun, creative, and practical ways. After much deliberation, we are pleased to […]

The post Beggin’ for a Beacon Xamarin Contest Winner! appeared first on Xamarin Blog.


Xamarin: Xamarin’s Got Game (Development)

If you’re new to game development, you may be wondering what framework is right for you. Luckily for C# and F# developers, Xamarin supports a wide range of powerful options like SceneKit and SpriteKit on iOS, as well as cross-platform frameworks including OpenTK, CocosSharp, and MonoGame. For developers just getting started, we recently published several […]

The post Xamarin’s Got Game (Development) appeared first on Xamarin Blog.