Hello there 👋🏻

Welcome to my blog about mobile applications development (mainly for Apple platforms).

➡️ Expect to read here about automated tests (unit, snapshot, UI), FRP, SwiftUI and many other topics that will improve your day to day coding. 🧑‍💻

➡️ I’m here not only to share, but also to learn. If you have any suggestion how I can improve my writting, feel free to reach me! 🤙

➡️ My name is Maciej and I’m going to be your guide through the world of mobile applications development. 🚀

📚 Enjoy the reading! 📚

#5 XCTest vs. Swift Testing - Conditional disabling - when a test needs a nap

#5 XCTest vs. Swift Testing - Conditional disabling - when a test needs a nap

Today we check the diff in conditional disabling. In XCTest there is XCTSkipIf function that takes Bool argument to decide whether a test should run or not. In Swift Testing there’s “disable” trait accepting Bool argument and behaving like XCTSkipIf from XCTest. XCTSkipIf - are you surprised this kind of function exists? To be honest - I was I can admit I learned about it when preparing this post. This already shows how often I’ll be using the Swift Testing version of it, but never say never!...

November 28, 2024 · 1 min · Maciej Gomolka
#4 XCTest vs. Swift Testing - Disable tests - handle with care

#4 XCTest vs. Swift Testing - Disable tests - handle with care

This week with Swift Testing starts with checking how test disabling differs from XCTest. In XCTest, Xcode identifies a function as a test only if its name starts with the “test” prefix, so putting e.g. “disabled” instead makes the test inactive. Swift Testing simplifies that approach by introducing the @Test macro with a .disabled trait that you can pass as an argument. What’s the benefit? You no longer need to modify each test name to disable it....

November 27, 2024 · 2 min · Maciej Gomolka
Two types of Swift macros

Two types of Swift macros

Explain # and @ in Swift - your next interview may have this question! Don’t miss it out! Shortly - # and @ are prefixes for macros in Swift. What is macro? 💡 Macro is a feature that generates code during compilation. Unlike macros in C, which work like “find and replace”, Swift macros are type-safe and context aware, making them powerful tools reducing boilerplate code. Two types of macros 1️⃣ attached - use @ prefix, tied to a declaration adding extra logic to it, like: @Test, @Model, @Observable 2️⃣ freestanding - use # prefix, standalone code like #expect, #Predicate, #warning...

November 26, 2024 · 1 min · Maciej Gomolka
#3 XCTest vs. Swift Testing - Unwrapping optionals

#3 XCTest vs. Swift Testing - Unwrapping optionals

Optionals are a core of Swift - we deal with them daily, both in production and testing code. Whether you write tests with XCTest or Swift Testing, unwrapping optionals is a common case. In XCTest there is XCTUnwrap operator. Swift Testing introduces #require macro. Is there any difference between them? Not really! Both require the test function to handle exceptions and try keyword before. Gif ⤵️ Code ⤵️ XCTest func testNewYorkTimeZone() throws { let newYorkTimeZone = try XCTUnwrap( TimeZone(identifier: "America/New_York") ) XCTAssertEqual(newYorkTimeZone....

November 21, 2024 · 1 min · Maciej Gomolka
#1 Swift code refactor in action - user profile name

#1 Swift code refactor in action - user profile name

Swift code refactor in action 👨🏻‍💻 Common scenario: formatting user profile name - I bet any of you faced this kind of task. At first glance, it look straightforward, but when you take a closer look, you’ll notice two potential improvements: 1️⃣ One single return - simplification of the function flow. 2️⃣ Centralised formatting logic - reduces the chance of bugs. Check out the animated gif and the code where I refactor to address these issues....

November 20, 2024 · 2 min · Maciej Gomolka