Blog

show all ·  general swift swiftui guest-article ·  ai android api appkit apps ar archive async-await authentication automation ci closed-source cocoapods codable colors conference conferences css dates device di docc document-group document-scanner dotnet environment-values error-handling extensions fastlane geo gestures git github html iap image-renderer images indie ioc ios javascript jekyll jquery keyboard keychain licenses lint localization macos mapkit ml mocking multi-platform objc open-source pasteboard php presentation-detents property-wrappers protocols quick-look realm rich-text scrollview searchable sf-symbols sheet slugify spm storekit subscriptions swiftgen swiftui-presentation tagging testing tvos typography uikit url-encode video vr watchos web webview xcode

The power of inout parameters

Feb 18, 2024 swift

In Swift, inout parameters can reduce code duplication and the amount of code needed to perform certain tasks. Let’s take a look.

Reflections on failing to reach out

Nov 8, 2023 general

My last month has been all about wrapping up and releasing a brand new major version of KeyboardKit. It has been a fun project…but failed to deliver on all the work that went into it.

Cleaner grid initialization in SwiftUI

Aug 30, 2023 swiftui

SwiftUI’s LazyVGrid and LazyHGrid are great for creating flexible grids. I however always find myself struggling with their initialization and have therefore created some utilities.

SwiftUI Prefers Semantics

Jun 15, 2023 swiftuiopen-source

SwiftUI get amazing updates every year. If you however have to support old OS versions, you may be unable to use the new tools, or jump through hoops to make it work.

DeckKit Updates

Jun 12, 2023 swiftuiopen-source

DeckKit 0.7 is out, with new shuffle support that makes shuffling a deck enjoyable. Let’s take a look at what’s new in this minor update.

SwiftUIKit Updates

Jun 12, 2023 swiftuiopen-source

SwiftUIKit 3.3 is out with some additions, like support for using Codable with AppStorage and SceneStorage, as well as new list utils. Let’s take a look at what’s new in this update.

Vision Pro - so many questions

Jun 5, 2023 general

Apple Vision Pro is finally unveiled! As a surprise to no one, it looks spectacular. However, for every rumor and question addressed today, new ones arised.

An App Group roller coaster ride

May 17, 2023 swiftswiftui

I’ve been struggling with a random bug when using an App Group to sync data between an app and a keyboard extension. The explanation: a combination of human error and Xcode.

Deep Dish Swift - Day 3

May 2, 2023 conference

Deep Dish Swift flew by and suggendly, the third and final day was here…way to soon. I’m impressed by the scale of this first edition of Deep Dish Swift, and really hope there will be a second installment next year. Let’s see what Day 3 had in store.

Deep Dish Swift - Day 2

May 1, 2023 conference

Deep Dish Swift Day 1 was one afternoon filled with amazing talks and getting the chance to meet many people from the community, ending with a deep dish at Giordano’s. Let’s get Day 2 going.

Deep Dish Swift - Day 1

Apr 30, 2023 conference

2023 flew by and Deep Dish Swift suddenly happened! This is a summary of the first indie dev focused day. Since the talks are not recorded, reach out to the speakers and invite them to your conference to get more people to hear the great stories they have to tell.

Sort git tags like a pro

Mar 26, 2023 git

If you like me use semantic versioning and have projects with a gazillion version tags, it’s nice to be able sort the tags in various ways. Let’s see how to sort Git tags like a pro.

DocumentGroup double back button fix

Dec 10, 2022 swiftui

If you are building DocumentGroup-based apps in SwiftUI, you may have noticed that apps that worked fine in Xcode 15 now show two back buttons when being built with Xcode 16.

Introducing LicenseKit

Nov 9, 2022 swiftclosed-sourcelicenses

When building closed-source software, you must not only protect your source code, but must protect the binaries themselves as well, so that you can distribute them without having to worry that they are used by people who shouldn’t access them. One way to do this is with software licenses.

Getting started with the SwiftUI NavigationSplitView

Aug 8, 2022 swiftui

SwiftUI 4 adds a new NavigationSplitView component that simplifies creating rich sidebar-based experiences on iPad and macOS, while automatically scaling down to a NavigationStackView (also new) on iPhone. It’s a powerful component that however can be a bit tricky to get started with, so let’s take a look at how to use it and some ways to style it.

Using QuickLook in SwiftUI

Jun 27, 2022 swiftuiquick-look

SwiftUI is growing with every new release, but there are still old treasures to be found in various Apple frameworks, that aren’t part of the core SwiftUI library. One example is MapView in MapKit, another is the amazing quickLookPreview view modifier in the QuickLook framework. Let’s take a quick look.

SF Symbols 4 variable colors

Jun 17, 2022 swiftuisf-symbolscolors

SF Symbols is an amazing iconography library, that is designed to integrate seamlessly with the various Apple platforms. SF Symbols 4 adds even more features to these symbols, where variable colors will let you communicate values with your symbols. Let’s take a look!

Slugify a string

May 30, 2022 swiftslugifytagging

In this post, we’ll take a quick look at how to slugify a string in Swift, which is nice if you want to generate tags, web urls etc.

Using the isEnabled environment value in iOS 14

May 20, 2022 swiftuienvironment-values

SwiftUI is amazing, but has a history of seriously buggy behavior. Even if you follow the documentation and your code compiles, you must still verify that it actually works if you target older iOS versions. As an example, let’s take a look at using the isEnabled environment value with custom button styles.

Presenting a SwiftUI view from DocumentGroup

May 16, 2022 swiftuidocument-group

The SwiftUI DocumentGroup makes it super-easy to create document-based apps. However, the api:s are currently very limited, which means that even the most basic things are hard to achieve. In this post, let’s take a quick look at how we can present custom SwiftUI views as modals from a DocumentGroup.

Git tags cheat sheet

Aug 26, 2021 git

In this post, I’ll list a couple of git commands that I found useful when cleaning up an unstructured git tag history. The post is primarily meant for future reference, but if you find it useful, that’s great.

Swift Semantics

Oct 16, 2020 swift

In this post, we’ll look at various ways to improve readability and writeability of Swift code by introducing extensions to Swift’s native types.

Url encode strings

Jun 4, 2020 swifturl-encode

In this post, we’ll look at how to url encode strings. We’ll then create an extension that let’s us do this easier and with less code.

Bind view geometry data to bindable properties

Mar 25, 2020 swiftui

SwiftUI is great for building declarative user interfaces. However, it’s still young and lacks many common things. In this post, we’ll look at a way to read geometry information from any view in a view hierarchy.

Building an Apple Watch app in SwiftUI

Feb 10, 2020 watchosswiftui

SwiftUI and Combine makes it easy to build apps for watchOS. However, if the app is part of a larger system, you may have to adjust your architecture. In this post, we’ll take a look at the work involved in building a SwiftUI/Combine-based app for Apple Watch.

SPM .gitignore excludes Xcode projects

Jan 2, 2020 spmxcode

When you create Swift Packages with swift package init, the generated .gitignore will exclude all Xcode projects by default. This will cause problems if you later add an Xcode project to your package.

Generic Swift protocols

Apr 5, 2019 swiftprotocols

For years, I’ve been struggling with combining generics and protocols in Swift. In this post, I’ll describe how I finally made sense of it all.

git grep

Mar 11, 2019 git

This is a short note to self about how to use git grep instead of grep to find all occurrences of a certain text in all files within a root folder.

Using structs like enums

Jan 30, 2019 swift

Swift enum and struct are two powerful tools. In this post, I’ll discuss how you typically use them and how to use structs like enums when you need more flexibility.

Coordinating async operations

Jan 26, 2019 swiftasync-await

Swift is an amazing language, but currently lacks good support for coordinating async operations in a sophisticated way. In this post, I will look at existing libraries for solving this, then discuss a lightweight alternative that uses a couple of simple protocols and implementations.

iPad Pro production setup

Dec 28, 2018 gitgithubjekyll

In this post, I’ll write about my process to find a more productive and flexible setup for my various sites, projects, blog etc. I’ll descibe how I moved away from my old hosting provider and Wordpress and found a setup that lets me create content on my iPad Pro.

Alamofire + AlamofireObjectMapper

Dec 27, 2018 swiftrealm

This is an updated version of a talk I gave at CocoaHeads Sthlm in 2017, on how to use Alamofire to communcate with an api, AlamofireObjectMapper to map responses, the Alamofire RequestRetrier to automatically retry failing requests and the RequestAdapter to adapt all requests. I also demonstrated how to use Realm to seamlessly add offline support, using the decorator pattern.

SwiftyDropbox crashes in Swift 4.2

Sep 19, 2018 swiftxcode

After installing Xcode 10 yesterday, I started migrating some libraries to Swift 4.2. While most migrations were painless, one failed, since it depends on SwiftyDropbox which doesn’t support Swift 4.2.

Automate setting up macOS

Aug 26, 2018 automationmacos

In this post, I’ll describe how to automate setting up a new Mac with a terminal script that will install system software and applications, configure the computer etc. This lets you setup a new Mac in minutes.

Codable magic

Feb 15, 2018 swiftcodable

I have finally started replacing all NSCoding objects in my code with the new Codable protocol. This article covers things that I’ve learned along the way.

Ditching RxSwift

Jan 19, 2018 swift

After hearing so many good things about RxSwift, I decided to use it in an app of mine. However, after struggling with it for months, I still haven’t found a nice setup and have now decided to ditch it.

A Swift Playgrounds Evening

Nov 10, 2017 swiftios

Tonight, I finally sat down with my oldest daughter Cornelia, to play with Swift Playgrounds and try to teach her a bit about programming.

Using iPad Pro with Working Copy

Nov 5, 2017 iosgit

In this post, I will write about my experience using Working Copy on my iPad Pro, adding a blog post to a Jekyll-powered blog, then pushing the result to GitHub.

New year, new habits

Jan 23, 2017 gitjekyll

I finally made it! After years and years of “I really should”, I have finally managed to abandon my old hosting provider, move all my sites to GitHub and start with some nice new habits for the new year.

Reset Xcode load plugin bundles warning

Sep 5, 2016 xcode

Today, I accidentally clicked “Skip Bundles” instead of “Load Bundles” when I started Xcode after adding new plugins. This cause Xcode to not load the plugins on subsequent launches. How can we fix this?

.NET Core notes to self

May 26, 2016 archive

I have been playing around with .NET Core since the early betas, but since I do so with rather long times in between, things break each time I pick up from where I left it. Here are some notes to self.

Reload DNX whenever a file changes

Dec 17, 2015 archive

I’m currently developing a console app in .NET Core on my Mac. It’s a rather nice experience, although I miss a lot of stuff from Visual Studio, e.g. build triggers. Let’s make DNX reload whenever a file changes.

Setup DNX in macOS

Dec 17, 2015 archive

After so much waiting, so many “I’ll do this first”, so much app coding etc. etc. (yep, I blame my family as well), I finally managed to start playing around with DNX and ASP.NET 5.

Update the title of an MKAnnotation

Sep 17, 2015 swiftmapkitgeo

I’m building a map app where users can save personalized content and present it with custom pins, icons, colors etc. I therefore need to update how an MKAnnotation is presented and its title.

Swift return statements and line breaks

Sep 10, 2014 swift

I’m currently porting some iOS games from Objective-C to Swift. While doing this, I stumbled upon something interesting in how Swift handles return statements and new lines.

Using Swift protocols in Objective-C

Sep 3, 2014 swiftdi

I’m currently creating two new games for iOS. One is made in Swift and SpriteKit, while the other is made in Objective-C and UIKit. To share logic, I need to use Swift protocols in my Objective-C code.

Mouse scroll sensitivity in Parallels Desktop

May 21, 2014 archive

I use Parallels Desktop to run Windows from a dedicated OS X partition. It works great overall, but one thing that I have had problems with, is that the mouse scroll sensitivity is too sensitive in Windows. Let’s see how to fix this in Parallels.

Scaling mobile at Spotify

Nov 6, 2013 conferences

This is a sum-up of a talk I attended at Øredev 2013, where Mattias Björnheden and Per Eckerdal from Spotify talked about how Spotify scaled their mobile teams.

Memory leak in iOS when mixing ARC and non-ARC code

Sep 10, 2013 ios

In an iOS app of mine, I had a situation where the app shut down after taking a couple of photos. The crash reports suggested a memory leak, but I had a hard time reproducing it. Turns out the leak was caused by mixing ARC and non-ARC code.

Hide the default Objective-C initializer

Sep 4, 2013 ios

Languages like Java and C# let you override and hide the default constructors of a class, to ensure that developers can only create valid instances of it. Let’s take a look at how to do the same in Objective-C.

Auto-increment Build Number in Xcode

Aug 23, 2013 xcode

When releasing new version of my iOS apps, I used to manually update the build number. However, a better approach is to have Xcode do it automatically. Let’s take a look at how to do it.

Android Activity Lifecycle Car Analogy

Aug 5, 2013 android

In most application frameworks, classes have a certain lifecycle that may be used to do customizations at the proper time. Let’s look at the Android activity lifecycle as compared to being a car.

Remove Android Activity Title and Icon

Aug 5, 2013 android

My getting-to-know-and-to-love Android journey continues, and has now come to themes. This morning, I have been learning how to use themes to customize the action bar and remove its icon and title.

Android Assets for Various Screen densities

Aug 2, 2013 android

Android devices come in a great deal of different flavors when compared to iPhone devices. They can be slow, fast, crappy, great, low-res and ultra-hd. To best honor the device running your app, you should provide assets for various screen densities.

Android Fullscreen Activity

Aug 2, 2013 android

The best way for me to get my act together when learning new things, is to write about it as early as possible. This way, I can return to my earlier posts and verify that I knew nothing once, and that I hopefully have learned a few thing along the way. Today, I thought that I should honor this strategy, by publishing a simple base class that can be used for fullscreen Android activities.

Run Lint in Android Studio

Jul 31, 2013 androidlint

As I have just started learning Android, I was happy to see that linting is such an integral part of the Android development process. Let’s see how to set it up in Android Studio.

Android Glossary

Jul 31, 2013 android

I’m currently getting started with Android development, which means that I have a lot of new stuff to memorize. It’s so obvious that the biggest challenge with learning a new language is not the syntax itself, but the tools and conventions. Let’s look at some acronyms that are worth remembering.

Windows 8 Activation Fail

Jun 7, 2013 archive

Unlike Apple’s outstanding OS X onboarding experience, Microsoft really have to step up the Windows onboarding. When you charge a lot of money for people to use your OS and require them to activate it, the activation must work. Sadly, it doesn’t.

Multiple SSH Files

Jun 7, 2013 git

When working with git, I use a single SSH key pair, which I use for e.g. GitHub. Today, though, I had to add a second key pair to be able to clone another remote repository.

UIViewController Custom Back Button Problem

Apr 23, 2013 ios

If you want your apps to have their own identity, you should put time into adjusting its appearance, such as fonts and iconography. One thing that may be tricky, though, is to replace the default back button with a custom one. It should be simple, but I just can’t get it to work in one app.

New legal label in MKMapView

Apr 15, 2013 iosgeo

I’m using Google Maps in a couple of iOS apps. Or, at least I was before Apple replaced Google Maps with their own engine. So, now I guess I use Apple Maps. And Apple Maps adds an annoying little label.

Perform web.config transforms on build

Apr 4, 2013 archive

In a current project, we are auto-creating deploy packages of an ASP.NET MVC web site, using Team City. When we do, we need to perform web.config transformations to ensure that a properly configured file ends up in the deployed package.

Natural Scrolling in Windows 8

Nov 29, 2012 archive

In OS X Lion, Apple introduced natural scrolling. It means that when you scroll, the scrollable content will move around like it was a sheet of paper you pressed and dragged around with your finger.

Oredev 2012 - Day 2

Nov 12, 2012 conferences

My second day at Øredev 2012 was amazing! When it was over, I had to sit down and take it all in. There were so many great talks, and I still had to skip many that I wanted to see.

Øredev 2012 - Day 1

Nov 7, 2012 conferences

I am happy to once again attend Øredev in Malmö, Sweden. Three days with great speakers and nice friends is just what is needed in the dark, Swedish November.

iOS Bounce Animation

Sep 3, 2012 objc

I have an app with a main menu, where users can swipe horizontally through a set of icons that take the user to certain parts of the app. When an icon is tapped, it bounces, plays a sound and takes the user to that particular part of the app. Let’s see how the bounce animation was made.

Localization in Objective-C

Aug 20, 2012 objclocalization

This post will show you how to localize your iOS apps, so they can be translated to several languages. I’ll will describe how to translate plain text and how to create localized versions of your storyboards.

CLGeocoder fails silently

Aug 8, 2012 objcgeo

I’m currently developing a location-based app for iPad and iPhone, that will allow users to store locations and use custom icons and colors for the pins.

Xcode - Disable ARC for individual files

Jul 25, 2012 ios

I am building an app that uses ARC (Automatic Reference Counting), which means I from now on will not have to handle memory management as actively as I have done before. There are still things you have to consider when using ARC, but it makes memory management a lot easier and less tedious.

JSON in iOS

Jul 4, 2012 objc

I’m currently creating an iOS app that will share data using JSON. Working with JSON is trivial in iOS 5, since there’s now a great, native JSON serializer and deserializer.

Adding photos to the iPhone simulator

Mar 13, 2012 ios

I’m currently building an iOS app that will make use of the device camera. It works well, but since I’m also running this app on the simulator, I want to be able to select pictures from the photo library as well.

Use Phantom/Boo to build, test and publish to NuGet and GitHub

Feb 22, 2012 archive

When building open-source, I used to handle the release process manually. Since each release involves executing unit tests, bundling, zipping and uploading to GitHub and NuGet, creating new git tags etc. the process was time consuming and error-prone. Since a release involved so many steps, I also released new versions quite seldom. Not good - automated build scrips to the rescue!

Øredev 2011 in the rear-view mirror – Part 1

Nov 23, 2011 conferences

Two weeks ago, I attended to the Øredev Developer Conference in Malmo, Sweden. I was there from Wednesday to Friday and it was truely inspiring. In this summary, I will write about sessions I attended, sessions I missed and a few sessions I heard a lot of good stuff about.

Tweaking NDepend CQL rules

Oct 6, 2011 archive

After learning on how to automate and schedule NDepend to run for several .NET solutions at once and starting to use NDepend more regularly, the power of CQL has grown on me.

Scheduling NDepend for a set of solutions

Oct 5, 2011 archive

In a project of mine, I use NDepend to continuously run a scheduled code analysis on a bunch of solutions that make up a large part of the software infrastructure of a major Swedish company.

EditorBlockFor HTML helper

Aug 28, 2011 archive

In ASP.NET MVC, Microsoft has done a nice job with creating various HTML helpers that can be used in a form, e.g. LabelFor, EditorFor, ValidationMessageFor. Let’s see how we can make our own.

Print screen in BootCamp using an Apple keyboard

Jul 7, 2011 macos

I have started to boot up Windows directly from my BootCamp partition on my iMac instead of running it under VMWare Fusion. This way, I don’t have to share resources with the OS X partition, which is nice for gaming, programming etc. There are however some rough edges.

Slow iMac about to be fixed?

May 12, 2011 macos

I have been having big problems with my iMac 27″ (4GB RAM) that runs Windows 7 on a Boot Camp Partition (using VMWare Fusion). It is basically the same setup as I have on my MacBook Pro (which has 8GB RAM), with the minor difference that the MBP is fast as lightning and the iMac is slow as HELL!

Custom ASP.NET validation attributes

Mar 23, 2011 archive

ASP.NET validation attributes is a great way of making it easy to validate C# properties in different ways, client and server side. Let’s look at how we can create our own validation attributes.

Hide the close button of a WPF window

Mar 14, 2011 archive

In a WPF application that I’m currently working on, I have to hide the close button of a progress window to prevent users from closing it manually. Turns out that it’s complicated, but perfectly doable.

Calculate geo distance and bearing in C#

Feb 4, 2011 archive

I’m currently building a gps-based web application that lets mobile devices post their positions to the app, which then replies with nearby items of interest. To do this this, the backend has to be able to calculate the distance between two geo coordinates. Here’s how to to do this in C#.

Trying out Plupload"

Feb 2, 2011 web

The team behind Tiny MCE has created a great file upload component called Plupload. It supports several runtimes – from jQuery-based uploads in HTML 4/5 to Flash, Silverlight, Gears etc.

Adding Spark to ASP.NET MVC 2

Jan 13, 2011 archive

I finally got some time to look at the Spark View Engine. Since the Razor View Engine will be shipped with ASP.NET MVC 3, I decided to give Spark a try first.

HTML5 localstorage

Dec 9, 2010 javascript

I have spent some time experimenting with the new HTML 5 localStorage feature, which is a new feature that simplifies storing data in the browser using JavaScript.

PHP magic quotes

Nov 24, 2010 php

About a year ago, I had problems when sending data to a php page, using AJAX. To be able to unpack the data, I had to use stripslashes. Since it seemed to work, I was happy…until the world exploded.

Getting started with git and GitHub

Oct 8, 2010 gitgithub

As some of my hobby projects are coming together, I have meant to move them from Google Code to GitHub for quite some time. Tonight, I decided to give it a try and say hello to git and GitHub.

NuPack - a quick walkthrough

Oct 8, 2010 dotnet

NuPack is a free, open source, developer-focused package manager for .NET. It looks absolutely awesome, so I downloaded it and gave it a try. Let’s have a look at how to use it.

Getting started with NDepend 3

Oct 7, 2010 dotnet

After some time, I have finally got my thumb out and added an NDepend project to one of my hobby project solution, to get some analyzing done. Let’s have a look!

Fonts.com web fonts

Sep 21, 2010 typographycssweb

The time has finally come to throw Arial and Verdana into the trash (Helvetica can stay for a while), as Monotype, Linotype and ITC (and others) have teamed up to develop a really cool service - web fonts!

Find the shortest path in a grid in XNA

Feb 22, 2010 dotnet

I’m currently playing around with a board game engine in XNA, where players can play missions that take place on a tile-based board. I’m now working on using the A* algorithm to find paths between tiles.

Generate a game board map from a bitmap

Feb 21, 2010 dotnet

I’m currently developing an adventure board game in XNA, where players can play missions that take place on a board that is made up of square tiles. It’s a lot like the amazing, old board game Hero Quest. In this post, I’ll describe how my custom-made game engine generates a board from a bitmap.

Load all assets in a folder in XNA

Jan 26, 2010 dotnet

I have started looking at XNA and am currently working with assets in a small game. This post show how to load all assets in a folder, which is convenient for smaller games where resources isn’t as critical.

Doxygen - A brief tutorial

Oct 7, 2009 archive

I’m using Doxygen to generate a web-based documentation for various .NET projects. This short post will show you how to configure Doxygen to achieve this.

Using Moq with NUnit

Aug 19, 2009 archive

As I continue to work with unit tests, I have noticed that some of my development patterns have started to change…for the better.

Using themes in ASP.NET MVC

Aug 19, 2009 archive

I have finally started creating my first web site with ASP.NET MVC. After looking through the nice start examples, I noticed that .css files were manually included in the master page. Let’s have a look at how to use ASP.NET themes instead.

Make URL rewriting in IIS 7 work like in IIS 6

May 18, 2009 archive

I’ve had a lot of problems with getting URL rewriting to work with Windows Vista and IIS 7. Compared to IIS 6, virtual paths in IIS 7 don’t allow extensions like .js, .css, which is problematic if you have shared files in virtual paths.

Identifying the project root in PHP

May 15, 2009 archive

I currently have problems with identifying the project root in a PHP project. The problem applies to PHP, but the discussion is general and applies to the other languages and environments as well.

Twitter vs Jaiku

Apr 17, 2009 general

I’ve been trying out Twitter and Jaiku for a while now. Since both provide more or less the same set of features, I have evaluated which I think will best fit my needs going forward.

Avoid empty img src values

Jan 26, 2009 htmlweb

In this post, we’ll discuss how empty image src values can ruin the performance of your web site, and how you can to solve it.