Latest weblog entries

2022-05-23 Xcode Package.resolved file is corrupted or malformed

Today Xcode gave me the error "Package.resolved file is corrupted or malformed; fix or delete the file to continue: malformed" when opening and running an xcworkspace with a Swift package and a sample app.

That is exactly after a successful pull request, so the project has built successfully before. The problem was fixed by manually removing the file, doing a "clean build folder", then quit Xcode and the simulator. Then started Xcode again and opened the workspace: it built. Just a tip for when you encounter this behavior.

In our case, Xcode actually downgraded some dependant package in (minor) version. So this may not actually be the final solution for you.

Note that this is NOT the same as the error that Xcode 13.2.1 or lower shows when someone else opened it with 13.3 or higher. From that 13.3 version and upwards, Xcode will upgrade the Package.resolved file to a new v2 format. But we never opened the project in any Xcode version higher than 13.2.1. That error reads: "Package.resolved file is corrupted or malformed; fix or delete the file to continue: unsupported schema version 2".

I'm not yet happy with the way Xcode handles Swift Packages, it feels unreliable in the current version. But it'll probably improve in the coming versions.

2022-04-06 Update on Firefox on macOS

A small update about Firefox on macOS. If you're like me, you're used to the close button on the left, including on tabs. I used to recommend the FirefoxCSS subreddit, but a better resource is the following gist on Github:

2022-03-28 Creating dotted line with StrokeStyle in SwiftUI

Here's an example of stroking a shape with a dotted line:

    struct ContentView: View {
        var body: some View {
                .stroke(style: StrokeStyle(lineWidth: 5, lineCap: .round, dash: [0,10]))
                .frame(width: 100, height: 100)

2022-03-03 Xcode Dependencies could not be resolved

Today, Xcode gave me the following error:

    Dependencies could not be resolved because root depends on 'customerkit' 13.0.0..<14.0.0 and root depends on 'customerkit' 11.0.0..<12.0.0.

The project had built correctly, then I wanted to edit code in a package so I added it as a local package.

The error was confusing to me, because it specifies that root (which means the current project, I assume) depends on both version 11.x and 13.x which is obviously not the case. So what this error message actually means, is: you added a local package, and both the main project and your local package rely on the same package (customerkit in this case), but they require different versions.

The fact that the error twice mentions "root depends on xxx", is thus wrong. If you get it, select your project in the left navigation, select the project again in the middle pane, select the Package Dependencies and look up the version of the dependency. In my case, that was CustomerKit, version "11.0.1 - Next Major". Now for the other packages, check their own dependencies and make sure these are equal.

2021-12-16 Switch with multiple cases with associated values

Lots of people know about switch cases with associated values, for example as follows:

    enum Emoji {
        case lol(String)
        case ohnoes(String)
        case nothing

Some code that uses the above enum:

    let testcases: [Emoji] = [
    for testcase in testcases {
        switch testcase {
        case .lol(let emoji):
            print("Happy emoji: " + emoji)
        case .ohnoes(let emoji):
            print("Sad emoji: " + emoji)
        case .nothing:
            print("No emoji")

If however, you have common code that must run for both happy and sad emoji, it's possible to combine them into one case. However inside that case, you can still test for one specific case. The example below shows how you can print common code for both happy and sad emoji, but still detect happy emoji:

    for testcase in testcases {
        switch testcase {
        case .lol(let emoji), .ohnoes(let emoji):
            if case .lol = testcase {
                print("Happy emoji detected: \(emoji)")
            print("This is code that runs on any emoji")
        case .nothing:
            print("No emoji")


Weblog Archive

Weblog entries 2021

Weblog entries 2020

Weblog entries 2019

Weblog entries 2018

Weblog entries 2017

Weblog entries 2016

Weblog entries 2015

Weblog entries 2014

Weblog entries 2013

Weblog entries 2012

Weblog entries 2011

Weblog entries 2010

Weblog entries 2009

Weblog entries 2008

Weblog entries 2007

Weblog entries 2006

Weblog entries 2005

Weblog entries 2004

All weblog entries


Articles, chronologically (latest first). This is pretty old stuff.


Not yet finished. Maybe will never be finished. Maybe they'll get deleted. Who knows?


System administration: