Xcode DocC - Getting Started
Jun 28, 2021, 5:55 AM
Xcode 13 brings a whole new system for creating documentation. Let’s see how to apply it to documenting a Swift Package.
I have a small Swift package for working with dynamic type named ScaledFont that I’ll be documenting as...
Xcode Column Breakpoints
Jun 21, 2021, 5:52 AM
Xcode 13 adds column breakpoints which work like a more granular version of line breakpoints. Here’s how you use them.
Xcode supports many different types of breakpoint but it’s the line breakpoint that I...
WWDC 2021 Viewing Guide
Jun 14, 2021, 8:42 AM
Here’s my viewing guide for the WWDC 2021 sessions I found interesting this year.
Where Do I Start?
Watch the Platforms State of the Union (SOTU) for a summary of what’s new. It has a demo of Xcode Cloud, Holly Borla...
Xcode Keyboard Shortcuts
May 31, 2021, 6:05 AM
I have a hard time remembering Xcode keyboard shortcuts. Here’s my cheat sheet of the ones I find useful enough to learn.
This is not a comprehensive list of every Xcode shortcut. There’s a limit to how many I can remember....
Core Data In Memory Store
May 24, 2021, 5:55 AM
Speed up your tests and SwiftUI previews by creating your Core Data stack with an in-memory store.
The Core Data stack uses an on-disk SQLite store by default. That causes some extra work when running tests as you need to reset the store...
Changing The Core Data Test Store Location
May 10, 2021, 5:36 AM
A quick tip to change the default directory for your Core Data database files when unit testing.
Where’s My Core Data Store?
If you’re using NSPersistentContainer to setup your Core Data stack it provides a default, platform...
XCTUnwrap Optionals In Your Tests
May 3, 2021, 5:21 AM
Writing unit tests that handle optional values can be a pain. Force unwrapping is concise but causes a crash when it goes wrong. Conditional unwrapping is tiresome and clumsy. Apple added XCTUnwrap in Xcode 11 to clean up the mess....
Debugging Core Data
Apr 26, 2021, 5:04 AM
Apple recommends adding some launch arguments and environment variables to your Xcode schemes to catch and debug Core Data problems. I’ve known about some of these for a long time others were new to me.
Xcode 12.5 Playground Access To App Types
Feb 8, 2021, 8:59 AM
Xcode 12.5 has enhanced playground support. When you add a new playground to a project it defaults to having access to the types in your App target. This means you are not forced to import frameworks or Swift packages to share code between...
SwiftUI Container Relative Shape
Feb 1, 2021, 9:58 AM
SwiftUI has lots of ways to create rounded rectangles but what if you want to match the corner radius of a widget? Apple added ContainerRelativeShape to iOS 14 for that purpose.
The Apple Human Interface Guidelines for widgets suggests you...
Widget Background and Accent Color
Jan 25, 2021, 6:16 AM
When you create a new Widget you may have noticed that it gets its own asset catalog. As well as the usual AccentColor this also contains a WidgetBackground color. What are these for and how are you supposed to use them?
You might hope...
SwiftUI Custom View Modifiers
Jan 18, 2021, 6:14 AM
Create your own custom SwiftUI view modifier when you want to reuse a set of modifiers on multiple views. Removing duplication also cleans up and improves the readability of your SwiftUI views.
Here’s my starting point. A SwiftUI...
Using Swift Result and flatMap
Jan 4, 2021, 10:08 AM
The Swift Result type is handy way to capture the results of a throwing expression that you need to execute on a background thread. Use flatMap to chain several results together.
The Swift Result Type
Apple added the Result type to the...
Swift If Case Let
Dec 21, 2020, 8:31 AM
The Swift If-Case-Let syntax is a convenient shortcut to avoid a full switch statement when you only want to match a single case. The syntax always seems backwards to me so here’s a reminder of how to use it.
Case Let - A...
Creating dynamic dark mode images at runtime
Dec 14, 2020, 8:44 AM
If you’re creating your images from the asset catalog you support dark mode by adding light and dark variations of the image. How about when you’re creating the images at runtime? How about when you’re using SwiftUI?
Showing Maps in Widgets
Dec 7, 2020, 7:56 AM
If you want to show a map view in a widget your first thought might be to use a MapKit Map view. Unfortunately WidgetKit doesn’t allow it. What you can do is create a snapshot of the map and show that.
I’m not going to cover...
Adding Views and Modifiers to the Xcode Library
Nov 30, 2020, 7:57 AM
Xcode 12 allows you to add your own custom SwiftUI views and modifiers to the Xcode Library. Here’s my quick summary of how it works.
The Xcode Library provides you a way to browse the available SwiftUI views and...
WidgetKit for iOS - Getting Started
Nov 23, 2020, 7:49 AM
Widgets seem to be the surprise hit of iOS 14. Here’s my guide to get you started building widgets with WidgetKit.
Widgets in iOS 14
Apple introduced widgets in iOS 14 at WWDC 2020. They allow you to show a small piece of your...
Slow Swift Compiler Performance
Nov 9, 2020, 11:52 AM
I went down a rabbit hole looking at Swift compiler performance this week. Since most of the diagnostic flags are unsupported they are not well documented. For future reference here’s my summary of what’s available.
iPhone 12 Screen Sizes
Oct 19, 2020, 5:39 AM
The 2020 iPhone release brings us four new models with three new device sizes including a 5.4" mini. Here’s a recap of what you need to know to update your Apps for the new devices.
The New Models In A Nutshell
The four new...
Using Swift Packages in Playgrounds
Oct 12, 2020, 11:06 AM
Xcode 12 playgrounds can now import and use Swift packages. It’s not the solution I was hoping for but it’s a step in the right direction.
I’ve written in the past about my attempts to add playgrounds to Xcode projects....
Launching iOS Apps with a Custom URL Scheme
Sep 21, 2020, 8:30 AM
I’ve been experimenting with widgets recently which led me to wanting to launch apps with custom URLs. Trying and retrying different URLs during development is tiresome and I couldn’t remember the different ways to do it....
SwiftUI Preview Data
Aug 31, 2020, 4:10 AM
One of the great features of SwiftUI is the Xcode support for previewing views without launching the simulator. This speeds up development but where do you keep your preview data? If you’re not careful your view code can become...
Stack View Background Color in iOS 14
Aug 17, 2020, 8:16 AM
Stack views show their background color in iOS 14! I recommend checking your storyboards. If you have inadvertently set a background color you’re in for a surprise when they show up when you build against the iOS 14...
Dropping launch storyboards
Aug 10, 2020, 10:18 AM
When Apple introduced SwiftUI at WWDC 2019 it seemed like the beginning of the end for storyboards. Unfortunately you still needed a launch storyboard for the system to show while your app launches. That changes with Xcode 12 and iOS...
Sharing data with a Widget
Aug 3, 2020, 11:29 AM
Apple introduced widgets in iOS 14 to allow you to show useful information from your app on the home screen. Widgets have limited functionality, they are not even interactive, but you’re likely want to share some data from your app...
Default initializer is inaccessible
Jul 27, 2020, 11:26 AM
Has the Swift Package Manager encouraged you to create a library for the first time? Are you wondering why the compiler is complaining that an initializer for one of your structs is inaccessible due to internal protection level? This is...
Add resources to Swift packages
Jul 20, 2020, 5:09 AM
Xcode 11 added support for the Swift Package Manager but it limited you to source code. In Xcode 12 you can add resources including things like asset catalogs, storyboards, Core Data models and more.
Adding Resources To Packages
Creating Lists with Collection View
Jul 6, 2020, 6:44 AM
Is this the beginning of the end for UITableView? Here’s my guide to building table-view like lists using collection views with iOS 14. Along the way we’ll also look at the new way to manage cell configurations and make use of...