TIL (Today I Learned)

Quick learnings, discoveries, and “aha!” moments. Short, focused posts with code snippets, tips, and tricks I pick up along the way.


iOS 26+ safeAreaBar

that we now use safeAreaBar from iOS 26+ to show the specified content as a custom bar beside the modified view

#swift #ios #swiftui


Swift 5.9 if/switch Expressions

With Swift 5.9 we can now use if and switch statements on the right-hand side of the = sign, like this:

#swift



Declared Age Range API

The new Declared Age Range API in enables us to request a user’s age bracket (e.g., under 13, 13–17, 18+) instead of exact birthdate.

#ios #api #privacy



LogForEachSlowPath Launch Argument

that we can use LogForEachSlowPath in the launch argument so SwiftUI can log warnings in the console for us.

#swift #swiftui #debugging


GitHub Slash Commands

GitHub issues/PRs have slash commands (public preview). Type / in any comment to get helpers like: /table (build a table) /details (collapsible block) /code (code block) /saved-replies (supports %cursor%) /template (insert issue/PR templates)

#github #productivity




Toolbar Title Features in iOS

In iOS 16+, use toolbarTitleMenu() to present a menu when users tap the navigation title.

#swift #ios #swiftui


Xcode 26 #endif Comments

Xcode 26 now shows the matching #if condition next to #endif. No more guessing or writing manual comments

#xcode #ios #productivity


Reset iOS Simulator Permissions

you can reset iOS Simulator permissions for your app without erasing the whole simulator

#ios #xcode #testing


SwiftUI Hierarchical Text Styles

that SwiftUI has five built-in hierarchical text styles you can use to visually prioritize content — just like system apps do!

#swift #swiftui #design


Shrink Video with QuickTime Player

If you need to shrink a video before attaching it to a GitHub PR, just open it in QuickTime Player → File → Export As → pick a lower resolution. Super quick!

#macos #quicktime #productivity


Xcode Loading Indicator

Xcode now shows a loading indicator when you are executing something

#xcode #ios


navigationSubtitle in iOS 26

iOS 26 now allows us to configure the navigation subtitle which was already there for macOS

#swift #ios #swiftui


UIDesignRequiresCompatibility for Liquid Glass Design

if you add UIDesignRequiresCompatibility to your Info.plist and set it to YES, your app will run using the old OS design instead of the new Liquid Glass design. Apple will remove this starting Xcode 27 so we have a bit of time to migrate.

#ios #xcode






UserDefaults Size Limit Notification

UserDefaults has a size limit, and Apple provides a notification for when you go over it: UserDefaults.sizeLimitExceededNotification

#swift #ios #userdefaults




SwiftUI privacySensitive Modifier

SwiftUI has a modifier that lets you hide sensitive information by adding a single line of code .privacySensitive() and it will automatically hide the view it’s attached to as soon as the app goes into the background

#swift #swiftui #ios


Button Repeat Behavior in iOS 17+

In iOS 17+, we can make a button trigger its action repeatedly if the user holds it. This makes it very easy for our customers to add the same item multiple times

#swiftui #ios


@frozen Attribute in Swift

The @frozen attribute in Swift indicates that a struct or enum’s layout is fixed and won’t change in future versions of the library or module where it is defined. This allows the compiler to make optimizations based on the assumption that the type won’t gain new stored properties (for structs) or...

#swift #performance


Parallax Effect in iOS 17

We can easily get the parallax effect from iOS 17 with just a few lines of code

#swiftui #ios


Localized String Comparison in Swift

When comparing strings that can vary by language or locale (e.g., backend-provided titles and locally stored titles in different languages), you can use String.compare(_:options:range:locale:) to handle case and diacritic insensitivity while respecting the system’s locale settings. More hereUse ....

#swift #ios #localization



Flash Scroll Indicators in SwiftUI

bout the scrollIndicatorsFlash modifier in SwiftUI (iOS 17+), which flashes the scroll indicators of scrollable views whenever a bound value changes. This is great for drawing attention to scrollable content, ensuring users don’t miss important information. Learn more in the official Apple docume...

#swiftui #ios


Lazy Variables Not Supported with @Observable

When migrating to @Observable, lazy variables are not supported. Replace them with computed properties or initialize them directly to ensure compatibility or use @ObservationIgnored

#swift #swiftui #ios



Start ScrollView at the Bottom

We can start a scroll view at the bottom with the .defaultScrollAnchor(.bottom) modifier.

#swiftui #ios


String Comparison Performance in Swift

When comparing two strings, it is always a good idea to search with String’s built-in method rather than directly comparing .lowercased() becauseThe method .lowercased() creates a new copy of each String every time it’s called, which might have a negative impact on performances.To provide a great...

#swift #performance #ios


Swift's zip() Function

Swift provides a solution with a built-in function called zip. This function allows for combining two sequences into a sequence of tuples, enhancing code cleanliness and readability.

#swift #ios


iOS 16 Color Gradient API

TIL: iOS 16 has an API that returns the standard gradient for the color self

#swiftui #ios