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

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.

Software Dev

It’s time to break up with your networking library for URLSession

๐Ÿ‘‰ https://tim.engineering/break-up-third-party-networking-urlsession/

Maybe URLSession is good to use on its own! I like this idea as a simplifier. Just use what you have! I just did this in some of my own code and was really happy with the simplified result.

This came from iOS Dev Weekly…

 I liked this article by Tim Miko on how to build a simple API client with no dependencies. There’s a simple playground example too.

iOS Dev Weekly #398

On the other hand, PromiseKit still looks amazing.