Today I learned

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!

Nestjs has great swagger decorators!


Nestjs has very great decorators to annotate your routes, dtos and controllers. This makes it really easy to keep your Swagger or OpenAPI documentation up to date.

https://docs.nestjs.com/openapi/types-and-parameters

Only downside: as TypeScript interfaces do not exist at runtime, you need to declare all your data transfer objects as classes, which might lead you to add convenience or validation methods to them. Don’t do it. These classes are just decorations.

XPath is powerful


XPath is a really powerful tool to query XML documents, if you are forced to. But in contrast to JSON queries, XPath does not return the actual values, but the nodes or attribtes you queried.

XPath ist ziemlich mächtig und man kommt relativ flott an das gewünschte Ziel. Anders als bei JSON queries erhält man aber nicht die eigentlichen Werte, sonder den Node oder das Attribut selber.

Static Table enums


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.

You can even use the CaseIterable protocol to count the number of sections or rows.

Reminder: base64 is not secure!


I have never actually seen serious code that’s running in production, that uses base64 encoding for password for over a decade. Today I did.

Here is the not so friendly reminder:

base64 is no encryption or hashing algorithm. You should not use it to encode passwords. And you should’t send the password over HTTP and Basic auth (no HTTPS, not even Digest auth). Even if you do, trade the password for a token. Don’t repeat your mistakes with every single request. And do not store the password locally. Store an encrypted session key instead.

If you don’t follow these basics, delete your code and shut down all your services.

SwiftGen has evolved!


I haven’t used SwiftGen for a long time, but wow, it has improved a lot. I am a bit impressed.

iOS apps require account deletion


Since WWDC21 all iOS apps that provide registration are also required to provide the deletion of those accounts.

Invalid Gradle Private Key


Gradle did reject my ssh key due to invalid privatekey.

The solution: converting it into a different format.

ssh-keygen-p -f id_rsa -m pem

CSS Rotate und Skew


With CSS skew you can simulate a perspective effect. If you want to additionally rotate the element, use rotate first then skew.

Otherwise you might get a really wierd result.

Swift and Firebase


Nothing especially new here, but a reminder: Firebase might be a good choice if you need realtime updates.

Instead of implementing and connecting to websockets and implementing one-time requests and observing differently, you can simply use getData or observeValue as they are already implemented.

Even some errors vanish when observing: you start by the cache and if there is no update due to errors, you don’t get new data. But beware: Firebase still might not be the best choice, depending on your app or the circumstances.