Swift
About Code written in Swift. My open source Swift projects are available at code.knabel.dev/swift-lang.
I had completely forgotten about NSDataAsset. Maybe I should move some of my JSON files into asset catalogs. According to @emergetools that should remove some code signing overhead from the app size.
Read »When using auto layout with a UIScrollView, subviews may not attach to the top edge of the scroll view’s parent. Else you cannot scroll, but the handle shrinks the more you scroll.
Starting with Swift 5.6 the Swift Package Manager can automatically detect Breaking API changes. Really great for libs!
Read »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.
Read »Cookies in WKWebView are broken. When manually setting a Cookie using the Configuration, it will be ignored by the web view.
Read »If the default Table Of Contents / Index Set for iOS does not fit your use cases. This library might be interesting:
Read »
Back in 2019 I wrote an article about how to debug your Swift Package Manager projects in Visual Studio Code. In late december 2021, the Swift Server Working group released a brand new extension for vscode, which dramatically improves debugging your Swift code. Especially for linux! Time for an update!
Read »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.
A few months ago Swift 5.5 has been released and made async/await available. And in 4.50.0 Vapor added support for it, too!
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 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.
Using enums in Swift for static Table View Data Sources is really great.
Especially when declaring them as enum X: Int and using the rawValue to reflect the section or row index.
I haven’t used SwiftGen for a long time, but wow, it has improved a lot. I am a bit impressed.
Since WWDC21 all iOS apps that provide registration are also required to provide the deletion of those accounts.
Nothing especially new here, but a reminder: Firebase might be a good choice if you need realtime updates.
Read »When using @main on a SwiftUI.App and @UIApplicationDelegateAdaptor(AppDelegate.self) you can still have an AppDelegate without handling SwiftUI manually as without @main.
Bitrise binary uploads cannot be updated after saving. Instead they need to be deleted and recreated. Thus all workflow steps need to be updated if they rely on the data.
Read »When maintaining multiple locales within your project, try to keep line numbers consistent across all locales. Also keep the order of translations consistent.
Read »Localizable.strings doesn’t support unicode \unnnn escapes, but only \Unnnn!
In Swift the \U is for UTF-16 escapes like \Unnnnnnnn.
How to detect a URL in a String using NSDataDetector - free Swift 5.1 example code and tips https://www.hackingwithswift.com/example-code/strings/how-to-detect-a-url-in-a-string-using-nsdatadetector
When setting the background color randomly in SwiftUI, you will be able to detect every single repaint! Might be helpful while debugging.
Read »Wnat your UICollectionViewCell transparent? Set alpha on contentView!
=> Setting alpha on the UICollectionViewCell itself doesn’t work.
UIImageView image is not animatable. Instead use transitions!

When developing Swift in Visual Studio Code there were a few cases, where I preferred Xcode. Beside the obvious cases like iOS Development, managing certificates and provisioning profiles, there was one big case left: Writing unit tests.
Read »The past few days I created a new server using Vapor and hit vapor new <project> --auth which created a Vapor 3 server. Later I upgraded the young project to Vapor 4, but found some lack of practical information about the upgrade on the internet. So here I share my subjective experience and try to give you some tips.

Editors like Visual Studio Code live from a wide range of extensions and customization. In contrast there are IDEs like Xcode and AppCode, which have everything set up and are ready to go. In order to provide a rich set of features, they cannot not offer the same level of flexibility. Which editor you might want to use is a highly personal decision.
Read »Running and debugging your targets in Visual Studio Code is not prepared by default. Especially for us Swift developers this might come unexpected, especially in comparison to Xcode. In VS Code we require extensions and configs for this purpose.
Read »The initial idea behind InferIt was to create some mixture of a constraint solver and a dependency manager: you would just tell it what to install and it would gather as much information as possible to install it.
Read »Async operators debounce, throttle or delay that functional reactive programming libraries as RxSwift and ReactiveSwift provide are super useful and expressive. Though their biggest benefit lays within composability.
A simple example implementation of the Redux pattern with multiple reducers and listeners.
Read »Archery is about doing something with your project’s metadata. The new version 0.3.0 puts everything on steroids and allows you to script your metadata. A detailed overview of all changes can be found on GitHub.
Read »Apple recently announced to develop a language server for Swift and C-family languages. Or said more clearly: Apple started development to support every editor implementing the language server protocol like VS Code, Sublime Text, Jet Brains‘ IDEs and Atom.
Read »A Swift Playground aiming to provide some functional helpers to parse arguments for command line tools. It uses Overture and is build for high composability, flexibility and little impact on your project’s freedom to evolve.
Read »Command mine is a concept of a swift library for parsing command line arguments. It is designed to support asynchronous implementations of CLIS, that may even be used inside frameworks.
Read »I excessively make use of the official Swift Package Manager as I usually do some CLIs or other stuff. For this use case it is really great. When developing Apps, Carthage and CocoaPods come in handy, which are great, too. For Web Development there are yarn and NPM, which support project based and global installs. Then there are gem (global) and bundler (project) for ruby based dependencies.
Read »