Latest weblog entries

2021-01-22 Error in SwiftUI Previews part deux

Today Xcode refused to show previews for one view, displaying "Cannot preview this file" on top of the previews canvas.

This time it's showing the error "SomeUnitTest.swift must belong to at least one target in the current scheme in order to use previews". I have the feeling that this error is incorrect and masks a problem elsewhere, because unittests most certainly should not belong to any other target than the test target.

I have been able to temporarily fix the problem as follows:

  • Quit Xcode and simulator
  • Delete the ~/Library/Developer/Xcode/DerivedData folder
  • Start Xcode and simulator
  • Remove all unittests from the project (don't move to trash, simply remove references)
  • Compile the project
  • Add the unittests back to the project

2020-07-16 Error in SwiftUI preview

Today, one SwiftUI Preview would not show anything. The Diagnostics button showed the following error:

    GenericHumanReadableError: unexpected error occurred
    noPreviewInfos(arch: "x86_64", sdkRoot: "/Applications/")

After a bit of fiddling, I found out the cause. This project had multiple targets. And the file was not a member of the currently selected target.

Edit 2021-01-15: the above solution was only temporary. Another attempt involved removing all unittests also temporarily "fixed" this problem. At the moment, this seems to be a very rare error and I have not been able to find a definitive cause or solution.

2020-05-27 Fixing a slow build in Xcode

If your Xcode project isn't compiling as fast as you expect, open the build settings of target that you're building. Add the following to the "Other Swift Flags" setting:

    -Xfrontend -warn-long-expression-type-checking=100

This makes the compiler emit warnings when it takes more than 100 ms to type-check an expression.

2020-03-05 Capping an array in Swift

Do you want to cap an array in Swift to a certain size? Here's how:

    var array = ["a", "b", "c", "d", "e"]
    array.replaceSubrange(3..., with: [])

The array now contains three items.

2019-12-08 Linux VPS with TeamViewer

In 2017, I blogged about setting up a Linux VPS at Vultr, then installing TeamViewer. This is an admittedly uncommon thing to do; most Linux servers are administrated over SSH. However for remoting into a desktop usage, I find TeamViewer extremely user friendly on the client side. The client itself is excellent, includes copy/paste, file transfer, chat, and a host of features. And it works on multiple platforms.

Today I tried once more to set up a VPS at, with a Fedora 31 desktop and TeamViewer. Unfortunately, I can no longer get it working; TeamViewer installs fine but the client hangs upon connecting. I hope to update once I get it working.

Updated instructions for CentOS 8 are as follows. Note this fails for unknown reasons, see below.

Log in as root. First install the desktop, enable GUI to start after reboot, and download and install TeamViewer:

 # dnf groupinstall workstation
 # systemctl set-default
 # wget ""
 # yum -y install ./teamviewer.i686.rpm

Edit the file /etc/gdm/custom.conf and remove the hash sign # before the line "WaylandEnable=false" so GDM uses

Add swapspace:

 # fallocate -l 1G /swapfile1
 # chmod 600 /swapfile1
 # mkswap /swapfile1
 # swapon /swapfile1

Add the following line to /etc/fstab:

 /swapfile1   swap    swap    sw  0   0

Add a user for yourself:

 # useradd -m -U mynewusername
 # passwd mynewusername

Add this new user to the sudo'ers file and reboot:

 # visudo
 # reboot

When done, reboot and log in at the Vultr website, because there, you can use your browser to access the graphical console. From there you can log into Gnome. It's important that you do this correctly; first click on the username. Now the password prompt appears. Next to the Sign In button, a settings icon appears. Click this icon, and make sure one of the options with "X11 display server" is selected! Continue to log in and you'll see the desktop. From here, you can start and configure TeamViewer.

Or at least, you should be able to. TeamViewer can be started, however the GUI never actually is displayed. The client will eternally hang in the "Connecting to <hostname>..." screen.


Weblog Archive

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: