Today I learned

Missing Async XCTests on Linux

Async tests do not work on Linux, only on macOS. Instead you need to implement a helper function that runs the test async by relying on expectations.

WKWebView Configuration Cookies not working

Cookies in WKWebView are broken. When manually setting a Cookie using the Configuration, it will be ignored by the web view.

Workaround: add a UserScript with the following code:

document.cookies = 'cookie_optin=essential:1|analytics:0'

That’s a great way to automatically reject Cookies and especially to disable tracking to either propagate the user’s ATT decision or to avoid implementing ATT in the beginning.

Getting your IP address

Sometimes you need your local IP address on the command line to automatically pass it to a script.

ifconfig en0 |awk '/inet / {print $2; }'

Swift custom table of contents lib

If the default Table Of Contents / Index Set for iOS does not fit your use cases. This library might be interesting:

UINavigationBar black after Xcode 13 upgrade

In case your UINavigationBar has been set to a custom color and the navigation bar is not translucent, you will experience a visual regression when updating to Xcode 13. The navigation bar background will be black - until you start scrolling. Then it behaves as expected.

Thankfully there is a workaround and an easy fix: Apple Developer Forums: barTintColor not working in iOS 15

Reminder: websites contain weird characters

Copying contents from the web often copies weird characters, like the invisible character U+FEFF or “Zero Width No-Break Space”.

Code editors like VS Code might highlight those characters depending on your config, but other websites don’t. In my case I copied a secret for my CI pipeline including the invisible character.

An easy workaround for this on the mac: Spotlight removes some of these characters. A simple cmd+space, cmd+v, cmd+a, cmd+c and esc cleans the copied text.

And suddenly the inserted password is correct!

There is a modular version manager: asdf!

Today I learned about asdf, which is a pluggable version manager.

Previously I used nvm, rvm, swiftenv and more. I now use asdf. Just add the plugin of your choice and install your desired versions.

The only drawback is installing completely new versions of the tools. You are only able to install exact versions. You can’t install some major 16 nodejs version. But you can still install asdf install <plugin> latest or in case of nodejs lts-* versions.

Don’t forget to pick the version locally or globally.

some side-tip: there is an asdf plugin for direnv!

Having two admin dev accounts is a bad idea

I tried to keep my work stuff separate from my personal stuff on the same machine. I created two admin users, set up a group for homebrew and set the permissions accordingly.

Sadly this didn’t work out in the long run. So I started to run Homebrew as my preferred admin user.

if [ "$(whoami)" != "vknabel" ]; then
  sudo -S --login -u vknabel bash -- $(which brew) "$@"
  brew "$@"

This approach worked and was muich more reliable than the previous approach.

Then came Flutter. I had to add additional permissions and eventually change their ownership from time to time as flutter messed them up.

Converting simple iOS apps to tvOS is easy!

Converting a simple and small iOS app was far easier than expected. Of course webviews, gesture recognizers, navbars, etc. are not supported or work differently, but at a first glance there are not a lot parts with visual regressions!

UIApplication.shared not in Extensions

UIApplication.shared isn’t available within an iOS app extension. To annotate your code paths not needed in an extension, but using UIApplication.shared, just use the @available(iOSApplicationExtension, unavailable) annotation.

Now you will receive the same error when using the annotated api from an extension!