URL(string:) Stopped Returning nil for Garbage in iOS 17. Your Validation Still Trusts It.
Since iOS 17, URL(string:) percent-encodes invalid characters instead of returning nil, so 'guard let url = URL(string: input)' accepts almost any text as a valid URL. Here's what changed, why it only kicked in when you updated Xcode, and how to validate URLs properly in Swift with scheme and host checks and URL(string:encodingInvalidCharacters:).
Your Request Signature Fails on One Request in Ten. JSONEncoder Never Promised You the Same Bytes.
Signing a JSON body with HMAC in Swift breaks when you encode twice, when a Dictionary changes key order, or when JSONEncoder escapes slashes as \/. Here's why JSONEncoder output isn't canonical, how it breaks webhook and API signatures, and the fix: sign the exact Data you send.
Your Base URL Has No Trailing Slash. URL(string:relativeTo:) Just Deleted Your /v2.
URL(string:relativeTo:) follows RFC 3986, so a base URL like https://api.example.com/v2 without a trailing slash quietly drops /v2 when you resolve an endpoint against it, and a leading slash on the endpoint drops the whole path. Here's why every request suddenly 404s, the xcconfig // comment trap that truncates your base URL, the URL equality and Codable surprises of relative URLs, and a safe join helper with a test.
JSONEncoder Sends Your Dates as Seconds Since 2001. Your Backend Thinks It's 1995.
Swift's JSONEncoder defaults to .deferredToDate, which encodes Date as a Double counting seconds from January 1, 2001, not 1970. Here's why round-trip tests never catch it, what it does to Node, Python and Go backends, and how to pin one date strategy for your whole app.
Codable Can't Tell You the Difference Between null and a Missing Key. Your PATCH Endpoint Can.
decodeIfPresent collapses an explicit JSON null and an absent key into the same nil, which makes 'clear this field' and 'leave it alone' indistinguishable. Here's the three-state wrapper that keeps them apart, and when you actually need it.
URLComponents Leaves the + in Your Query Alone. Your Server Reads It as a Space.
URLComponents.queryItems percent-encodes spaces and ampersands but leaves + untouched, and most servers decode + as a space. Here's why mario+test@gmail.com arrives as 'mario test@gmail.com', and the one-line fix.
Swift's uuidString Is Uppercase. Your Backend's UUIDs Aren't. Every String Comparison Between Them Fails.
UUID().uuidString returns uppercase hex while Postgres, JavaScript and Python emit lowercase, so string comparisons, dictionary keys, cache file names and Set deduplication silently miss. Here's where it bites in iOS apps and how to keep UUIDs typed until the boundary.
Your Date Decoding Worked for a Year. Then the Backend Added Milliseconds.
JSONDecoder's .iso8601 date strategy rejects fractional seconds, so the day your API starts sending 2026-10-05T09:31:00.482Z every request fails to decode. Here's why the strict parser exists and the custom strategy that handles both shapes.
Codable's Snake Case Conversion Looks Like Free API Mapping. It Breaks on the First Acronym.
JSONEncoder's .convertToSnakeCase and JSONDecoder's .convertFromSnakeCase promise to erase the naming gap between Swift and your API. They do — right up until a property has an acronym in it, and then they fail silently on Optional fields instead of throwing.
Your Upload Doesn't Stop When Your App Gets Killed. It's Not Supposed To.
URLSession background sessions keep uploads and downloads running after iOS terminates your app — but only if you set them up before the crash, not after. Here's the delegate dance nobody reads the docs closely enough to get right.
The Actor That Refreshes Your Token Perfectly. It Also Forgets It on Relaunch.
AuthTokenStore solved the token-refresh race condition with a Swift actor. What it never solved is where the token lives between launches. Here's why an in-memory actor isn't secure storage, and what a Keychain-backed version actually costs you.
Typed Throws in Swift 6: A Real Migration, and the Wall It Hits at a Protocol
Swift 6's typed throws (throws(SomeError)) let you catch errors exhaustively without a default case. Applied to BrewLog's real NetworkClient, here's what actually improves — and the protocol boundary where typed throws quietly stops helping.
Swift Just Got a Real Timeout API. Here's What We've All Been Duct-Taping Instead.
SE-0526 withDeadline was accepted into Swift on July 30, 2026 — a real, composable, absolute-time-limit API for async operations. I found the exact gap it fills in a real app's networking layer, fixed it today's way with a TaskGroup race, and lined it up against what withDeadline will let me delete once it ships.
Retry, Token Refresh, and Request Deduplication in Swift
Day 23 of the 30-day iOS series. The three production concerns every 'build your own networking layer' tutorial skips, built as composable actors on top of Day 22's client — plus a real concurrency bug I found writing the test, not the code.
A Custom Networking Layer in 100 Lines of Swift — No Alamofire
Day 22 of the 30-day iOS series. URLSession, async/await, a generic Endpoint, and one typed error enum — the entire networking layer is 85 real lines, tested with a URLProtocol stub, and wired into a real BrewLog feature with a real local server.