Fixing SwiftUI Previews That Won't Load
When SwiftUI previews fail with cryptic errors or just spin forever, here's how to diagnose and fix the most common causes.
// 182 articles available
When SwiftUI previews fail with cryptic errors or just spin forever, here's how to diagnose and fix the most common causes.
Xcode 26.3 ships with a built-in MCP server that exposes project structure, build actions, and test results to external AI tools. Here's how to set it up.
Change where Mac screenshots save with Cmd+Shift+5 then Options, or run defaults write com.apple.screencapture location in Terminal. Takes 30 seconds.
Avoid cryptic build failures by setting up nvm to automatically use the right Node version when you cd into a project.
Learn how to access your app's App Delegate from anywhere in your Swift code, including from SwiftUI views.
Learn how to access photos from the camera roll in SwiftUI, including required permissions, Info.plist configuration, and using PhotosPicker for iOS 16+ or UIImagePickerController for earlier versions.
Learn how to detect when users take screenshots in your SwiftUI app by observing UIApplication notifications.
Learn how to add horizontal padding inside a TextEditor without affecting the scrollbar using the contentMargins modifier introduced in iOS 17.
Stop macOS from writing .DS_Store files to network shares and USB drives with one Terminal command. Keep your repos and external drives clean.
Learn how to use the presentationDetents modifier to control sheet heights in SwiftUI, creating interactive bottom sheets similar to Apple Maps and Music.
Learn how to use ToolbarSpacer to add fixed and flexible spacing between toolbar items in SwiftUI, new in iOS 26.
Learn how to detect app lifecycle changes in SwiftUI, save state when your app enters the background, and restore it when users return, using scenePhase and UIApplication notifications.
Learn how to detect when users enable Low Power Mode and automatically reduce animations, refresh rates, and visual effects to preserve battery life in your SwiftUI app.
Learn how to detect when a user successfully shares content using a share sheet in SwiftUI by wrapping UIActivityViewController.
Learn how to create a Material Design-style floating action button in SwiftUI that intelligently moves above the keyboard and avoids blocking text input fields.
Learn how to add custom toolbar buttons above the keyboard in SwiftUI using the .toolbar modifier with keyboard placement for Done buttons, formatting controls, and more.
Learn how to prevent users from taking screenshots of sensitive content in your SwiftUI app using field-level security and UIKit bridging for financial, medical, or private data protection.
Learn how to add pull-to-refresh functionality to custom ScrollViews in SwiftUI without using List, perfect for custom layouts and complex scroll content.
Learn multiple approaches to replace characters and substrings in Swift strings, from simple replacements to pattern-based transformations.
Learn how to build skeleton loading screens with animated shimmer effects in SwiftUI using gradients, AnimatableModifier, and reusable view modifiers for a polished loading experience.
Learn how to implement undo/redo functionality in SwiftUI using UndoManager, including environment injection, registering actions, and creating undo buttons for professional editing experiences.
Learn how to prevent users from dismissing modal sheets by swiping down in SwiftUI using interactiveDismissDisabled.
Learn how to use Xcode's Device Conditions feature to simulate thermal state and network conditions to test your app under real-world stress scenarios.
Add an AppDelegate to a SwiftUI app with @UIApplicationDelegateAdaptor to handle push tokens, launch options, and lifecycle callbacks SwiftUI lacks.
Learn how to symbolicate crash logs from App Store Connect and Xcode Cloud to debug production crashes effectively.
Learn how to access SwiftUI environment values in View extensions using ViewModifiers for clean, reusable code.
Learn how to create and display QR codes in SwiftUI using Core Image filters.
Find any SF Symbol by name without leaving Xcode, using the Library panel search and a few shortcuts.
Read an environment variable in Swift with ProcessInfo.processInfo.environment["KEY"]. Set values per scheme in Xcode or pass them to xcodebuild in CI.
Learn how to dump all SwiftUI environment values for debugging purposes.