RSSAmplifier

Blog

Code - Cube Free Coder

Recent content in Code on Cube Free Coder

cubefreecoder.comRSS feed ↗10 posts

Latest posts

Creating Marketing Resources with ButterKit

ButterKit is a fantastic resource. Creating screenshots, uploading App Store connect metadata, localization, it does it all. Buy it once forever, or just subscribe for when you need it. Made by a passionate developer who is actively listening to feedback and improving the product. It’s one of those tools you dream of as a developer. Recently I’ve been extending those capabilities into…

Editing multiple occurrances in Xcode (with Vim)

Here is a real gem of a tip burried deep within the Swift 6 migration video to edit multiple occurances of a word/keyword in one fell swoop. Select the text If you are sitting at the first character in the word, use ve to select to the end of the word. If you are in the middle of the word, viw will select the entire thing. Press Cmd+Opt+e to select the next occurance.

Querying SwiftData with a date-based Predicate

I was working on a project where I needed to query items from swift data that occurred on a specific date. When dealing with dates, my first instinct is usually to reach for the Calendar object to do all the heavy lifting for me. This lead me to have something like: private func fixturesHappeningToday () -> [ LocalFixture ] { let predicate = # Predicate < LocalFixture > { item in Calendar .…

Swift Calendar favorites

The Calendar class in Swift has so many useful helper methods to make working with dates easier, and less error prone. A couple of my absolute favorites: isDateInToday(_ date: Date) -> Bool Simple and to the point. let occursToday = Calendar . current . isDateInToday ( someDate ) isDate(_ date1: Date, inSameDayAs date2: Date) -> Bool Say you have two dates returned from a server as UNIX…

Advancing Date values in Swift

Swift makes it easy to advance a Date value by a given number of seconds. Just use the .addingTimeInterval() method. let date = Date . now let sixtySecondsLater = date . addingTimeInterval ( 60 ) let twentyMinutesLater = date . addingTimeInterval ( 60 * 20 ) // Negative values also work just fine let sixtySecondsAgo = date . addingTimeInterval ( - 60 ) For a more readable, and less error-prone…

Location validation in Swift

Swift makes it super easy to create a location. Just give it your latitude and longitude: let someLocation = CLLocation ( latitude : 40 , longitude : - 40 ) Easy! Too easy? The slight catch here is that there is no validation being done. You can create a completely invalid location and Swift won&rsquo;t complain at all. No compiler errors, no runtime errors. If you log the bad location, you can…

Manually installing the iOS 17 simulator runtime for Xcode 15 beta

If you just downloaded the Xcode 15 beta from the Apple Developer website, you might have ended up with two files: Xcode_15_beta.xip and iOS_17_beta_Simmulator_Runtime.dmg If you launch Xcode you&rsquo;ll see that the iOS 17 simulator is still missing, and you won&rsquo;t be able to build and run with it quite yet. The good news is that it is easy to manually import the simulator runtime, and you…

backgroundTask modifier crashing Swift compiler

As of Xcode 14.0, adding a backgroundTask modifier to anything more than a single view will likely cause a not super-helpful compiler error. Say you have something like this: @ main struct WeatherApp : App { @ StateObject var weatherData = WeatherDataStore () var body : some Scene { WindowGroup { SimpleWeatherView () . environmentObject ( weatherData ) } . backgroundTask (. appRefresh (…

Feedback most welcome

I woke up this morning to find out that I had gotten a response to a Feedback Assistant bug I had filed for a recent beta version of Xcode. The issue was around the re-ordering of the new document tabs. This really made my day that someone took the time to fix this. It was such a small issue, but was annoying enough that I actually submitted a Feedback Assistant, something I haven&rsquo;t done too…

What's new in Xcode 12 ... ?

One of my favorite sessions to watch from WWDC each year is the What's new with Xcode . As I quickly scanned the videos from this year I realized it was missing. What gives? As I&rsquo;ve been making my way through the videos though, I have realized that it is there, just in a much more subtle way. The pre-recorded session videos allow for a much tighter experience. Not only can more content be…