vankuik.nl

Latest weblog entries

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/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.6.sdk")

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.

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 Vultr.com, 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 graphical.target
 # wget "https://download.teamviewer.com/download/teamviewer.i686.rpm"
 # 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 X.org.

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.

2019-09-16 Objective-C project without storyboard in Xcode 11

Create a new project and open the ViewController.h. Optionally add the following lines to viewDidLoad:

    self.view.backgroundColor = [UIColor greenColor];
    self.title = @"My first viewcontroller";

Then open the SceneDelegate.m file and add the following lines to the scene:willConnectToSession:connectOptions function:

    ViewController *vc = [ViewController new];
    UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc];
    
    UIWindow *window = [UIWindow new];
    [window setWindowScene:(UIWindowScene *)scene];
    window.rootViewController = nc;
    self.window = window;
    [window makeKeyAndVisible];

Run the project. You should now be able to see a green viewcontroller.

You can delete the Main.storyboard file, then go to the project, click on the target, and in the General tab, clear the "Main Interface" textfield. Then open the Info.plist, click open Application Scene Manifest, Scene Configuration, Application Session Role, Default Configuration, then click the minus button next to Storyboard Name.

More...

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

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: