Issue #51
Hi there, welcome to the 51st issue of iOS Code Review! I hope the summer is treating you well ☀️ Let's learn something new!
Join 4500+ fellow mobile DevOps practitioners virtually for a two-day event packed with the latest trends, best practices, and hands-on workshops from the industry experts. Register for free today!
Register for free
Check your third party dependencies
Last year I gave a talk on Mobile DevOps Summit 2022 about protecting your app from malicious code in third party libraries. That's also why I'm extra excited that they're sponsoring the newsletter 😄
In short, code in a framework gets access to your whole view hierarchy and memory, so they could steal your user's data. In the talk I give tips on how to check that a library isn't doing what it isn't supposed to.
You can find all recordings from last year on Youtube.
Shuffling arrays
Don't know who needs to hear this, but there's a set of handy methods for randomly shuffling any array.
There's shuffle()
and shuffled()
, and companion methods that take a random number generator. A custom generator can implement, for example, a reproducible ordering - while the default one (SystemRandomNumberGenerator
) makes it as random as it can be:
On skipping tests
How does Xcode know which tests to execute? It looks for classes conforming to XCTestCase
, and inside them for any method starting with test
.
So one way to temporarily disable a test is to comment out or rename the method so it doesn't start with test
.
There's a better way though - we can conditionally skip tests by calling XCTSkip
, XCTSkipIf
and XCTSkipUnless
:
Swift Macros - something's coming!
Swift Macros are so powerful, I'm yet to comprehend how much they will change the way we do things in Swift. I'm looking forward to using them in production apps starting from September.
Here's two down-to-earth examples where they can simplify our coding life:
✌️
Alright, that's it for today!
Thank you to Bitrise Mobile DevOps Summit for sponsoring this issue ❤️
I'm curious if you found any of the tips particularly interesting - let me know by replying to this email!
Member discussion