vankuik.nl

Latest weblog entries

2022-11-18 Example of hierarchical list

I actually didn't know that the SwiftUI List element natively supports hierarchical lists, until someone on Reddit asked for an example. Here's mine:

    struct Park: Identifiable {
        let id = UUID()
        let name: String
        let children: [Park]?
    }
    struct ContentView: View {
        private let parks = [
            Park(name: "Sierra Nevada", children: [
                Park(name: "Yosemite", children: [
                    Park(name: "Mount Dana", children: nil),
                    Park(name: "Mount Lyell", children: nil),
                ]),
                Park(name: "Stanislaus National Forest", children: [
                    Park(name: "Emigrant Wilderniss", children: nil),
                    Park(name: "Carson-Iceberg Wilderniss", children: nil),
                ])
            ])
        ]
        var body: some View {
            List(parks, children: \.children, rowContent: { Text($0.name) })
        }
    }

2022-09-15 Xcode linker error ld framework not found

Today I got the following error when trying to build my unittest for my Swift package:

  ld: framework not found CoreAPIKit

Note that the name of that particular framework (CoreAPIKit) doesn't matter; it's a framework that's only used internally at my client. Now on to the solution... In Xcode, we selected the project, and selected the unittest target, then selected the Build Phases tab. In that tab, there's the Link Binary With Libraries setting.

That setting listed "CoreAPIKit.framework"! So, why does this go wrong?

We removed that framework, then added it again. This time, it was saying "CoreAPIKit" (i.e. without the extension). Now, the unittest target correctly linked.

2022-09-14 Getting an unescaped JSON string from Xcode console

If you're debugging an app, you may want to copy raw JSON in Xcode, then paste it into a specialized app. The problem is, Xcode doesn't make it obvious how to actually do this.

In my first attempt, I set a breakpoint at the appropriate line of code, and Xcode listed the variables in the Variables View. In my case, that variable was called "response" of type "optional Data". So I first tried typing the following at the debugger prompt:

  ldb> po String(decoding: response.data ?? Data(), as: UTF8.self)

This however will print the string but it will escape all quotes with a backslash. To be able to select and copy unescaped JSON from the console, type the following:

  ldb> e print(String(decoding: response.data ?? Data(), as: UTF8.self))

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:

https://gist.github.com/henrik242/3abf4c52ebf81add5cfe38acf97c2053

More...

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

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

Scribblings

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

Programming:

System administration:

Others:

Files: