Widget Previews in Xcode 12

WWDC2020 was chock full of exciting announcements. One the new things Apple introduced was WidgetKit, which enables us to add multi-platform widgets to our apps. I find this quite exciting and a great fit for my app Solar Watch and started experimenting right away. Go ahead and watch the WWDC videos related to widgets.

WidgetKit is a great framework which comes with two catches:

  1. The widgets cannot be interactive. But can contain buttons which deep-link into different parts of your app.
  2. The widgets must be implemented in SwiftUI. Which is not bad per se but means more work if you would like to quickly build a widget extension for your existing app.

This is a great reason to learn SwiftUI, if there ever was one!

When I started experimenting with different widgets, I could not get the SwiftUI previews to work. It kept erroring out with PreviewAgentError: Statically rendering previews is not supported on iOS simulators.

This seems to be a bug in Xcode 12 beta 1 (FB7797517). I’m sure it will get fixed quickly but in the meantime here is a workaround that you can use to preview your Widgets:

static var previews: some View {
  return Group {
    MyWidget()
      .previewContext(WidgetPreviewContext(family: .systemSmall))
    MyWidget()      
      .previewContext(WidgetPreviewContext(family: .systemMedium))
    MyWidget()
      .previewContext(WidgetPreviewContext(family: .systemLarge))
  }
}

And here is how it looks like for the SolarWatch Widget I am working on:

This works pretty well but the downside is it only works for subclasses of Widget. Also you’ll have to switch back and forth between your widget class and the view that you are working on.

Feel free to reach out over Twitter if you’ve found another solution.

I spent the last few days computing the true sunrise/sunset times when the sun actually appears behind the terrain.

Coming in the next @solarwatch update.

My Mediterranean interpretation of Pho Ga. Entering 2020 with a cold, eating chicken soup, in pyjamas.

Experimenting labels which follow your touch in @solarwatch. Laying them out correctly is going to be hairy. Open for ideas and suggestions.

I’ve been working on the yearly overview for @solarwatch today. This screen has potential for a lot of astronomical data visualization. It will be fun to design it.

Five years of UIKonf

UIKonf is an independent international conference in Berlin about developing apps on Apple platforms and I have been involved in organizing it since 2014 after Sabine, Maxim and I took over from the original team Chris, Peter and Matt.

We took the conference from about 200 attendees to about 500 while still keeping the open, social and inclusive atmosphere, which is the defining characteristic of UIKonf. When we first started, I remember being very worried about if we could sell enough tickets to cover the costs and if great speakers from all over the world would accept our invites and show up but it all worked out. UIKonf quickly outgrew its original home venue and found a new bigger home by the river Spree.

In addition to inviting experienced speakers, it has been always very important to us to be able to give new voices a platform to be heard. We have been running a double-blind call for proposals from the beginning in order to give everybody a level playing field. Many of UIKonf’s best talks were not invited but were submitted to our CfP and selected by the community.

But a great atmosphere, a great location, great speakers are only part of the story. Our industry is infamous for its lack of diversity. We worked very hard to achieve a diverse speaker line up on stage at UIKonf. Year after year we kept doing our part, but year after year others did not think twice about putting all-white-men on stage, because “finding women speakers is hard”.

We decided to raise more awareness about this problem: we organized a line up of 18 great women speakers 1 for UIKonf 2019. When we announced our decision, we were overwhelmed by all the emails of support and encouragement we received. Endless thanks from the bottom of my heart for your support. Go watch the talks and see for yourself that “finding women speakers is hard” is nothing but a cheap excuse.

Organizing the last five years of UIKonf have been an amazing experience and when I look back, I am very proud of what we achieved as a team but have decided that it’s time for me to move on. UIKonf takes a lot of time and energy which I want to focus on my other projects and my family going forward.

It was a unique privilege to be able to organize UIKonf and I am very grateful for the love and support by our community. I cannot thank Sabine, Maxim, Julia, Bianca and last but not least Chrissy enough, who all put in a lot of effort into organizing UIKonf. It was a pleasure working with you!

It’s a bitter sweet departure for me but I am happy to know that UIKonf is in experienced and capable hands with Sabine, Julia, Bianca and Chrissy and they will do an amazing job of taking UIKonf further. I am hugely looking forward to attend UIKonf 2020 and actually to be able to take part in the social events and watch the talks for a change!

Footnotes

Footnotes
1 and we could have invited more but we only have 18 speaking slots.