Software Dev

Swift Sourcery

Meta-programming for Swift, stop writing boilerplate code

๐Ÿ‘‰ Sourcery

I haven’t tried this yet, but it sounds interesting if you find yourself writing repetitive code and can’t find another way around it. I gather it generates code from some sort of template.

Sourcery is a code generator for Swift language, built on top of Apple’s own SourceKit. It extends the language abstractions to allow you to generate boilerplate code automatically.

Software Dev

Detecting Changes to Network Access on iOS 12+

Holy crap, there’s finally a dedicated iOS API (NWPathMonitor) that detects and monitors network status!

๐Ÿ‘‰ Detecting Internet Access on iOS 12+

We’ve been dealing with or avoiding the problem of network connectivity on iOS apps for years. Now you can monitor the network status with a callback sort of like you would with location or other services. And you can specify wi-fi or cellular.

I’m glad this finally made it to the to of Apple’s backlog! ๐Ÿ‘

Software Dev

33 and โ…“


As noted in this post , I’ve been swimming at a pool that is 33 โ…“ yards (100 feet) long instead of the usual 25 years. I had been tracking this length as 33 yards on my Apple Watch. But recently they added an actual “33 โ…“” length between 33 and 34. Even though that โ…“ of a yard doesn’t make a real difference to me in terms of health tracking, this still made my day because they were thinking of me and this weird pool. ๐Ÿ‘

It shows what kind of impact attention to detail can have in a user interface. What can I say? I feel understood. ๐Ÿคท๐Ÿปโ€โ™‚๏ธ

Software Dev

Hopper Disassembler

If you ever find yourself having to debug someone else’s code without access to their, uh, code, then this disassembler may be the tool for you.

Also, good luck and may the force be with you, friend. ๐Ÿ˜ณ๐Ÿคฏ๐Ÿค“

https://www.hopperapp.com

Hopper Disassembler, the reverse engineering tool that lets you disassemble, decompile and debug your application

Looks like you can decompile Linux and Mac code (include Swift), but not iOS.

Software Dev

Decompiling Swift’s โ€œdefer” operator

The Swift “defer” operator my not work exactly like you expect. It’s not exactly the last code executed before the function returns. Well, it kind of is. But also not so much. ๐Ÿคฆ๐Ÿปโ€โ™‚๏ธ As this article says, “defer” basically happens at the “ret” in “return”. ๐Ÿคฏ

It takes a while to process whatโ€™s going on here, so take your time…

https://medium.com/@sergeysmagleev/how-defer-operator-in-swift-actually-works-30dbacb3477b

It’s also fascinating to see how what some very simple Swift code looks like when decompiled. Temporary registers. Global var access. Code injection in all the wrong places. ๐Ÿคฏ I have newfound respect for compiler writers.

And thanks to Sergey Smagleev on Medium for a great deep dive into “defer”.

Whoa, a simple three-liner has turned into this abomination that spans 34 lines of code.