RSSAmplifier

Blog

A+ programming moments

Recent content on A+ programming moments

aplus.rsRSS feed ↗20 posts

Latest posts

Issue with SPM unable to resolve package update

Xcode 26.4 brought nice new usage possibility in the Package manifest. I discovered it through lovely package resolving error when attempting “Update to Latest Package Versions”: unexpectedly did not find the new dependency in the package graph: sourceControl( identity: idensicmobilesdk-ios, location: SwiftPM.SPMPackageDependency.SourceControlLocation.remote(…

Crash with callback methods in parent-child data sources

Say I have ParentDataSource which holds a strong reference to ChildDataSource , which has a callback method that ParentDataSource implements: final class ChildDataSource : NSObject { var dataRefreshed : () -> Void = {} } final class ParentDataSource : NSObject { let childDataSource : ChildDataSource init (...) { ... childDataSource . dataRefreshed = { [ unowned self ] in self . doSomething () } }…

How to use custom variable fonts in UIKit

If you go with the solution 1 to the previously discussed issue , I strongly suggest you embed variable fonts inside your app. Taking a look at Google’s Roboto font family , it has 54 static fonts which takes up ~8MB. There are just two variable font files though, each less than 500kB. These two files contains condensed and standard widths , 9 different weights in both normal and italic…

The Mystery of black italic condensed UIFont

Today I encountered frustrating issue while working on custom font styling in an iOS app. I needed to create italic system fonts with custom weight and width variants - something that should be straightforward with UIKit’s font descriptor API. Spoiler alert: it wasn’t. The Initial Setup I started with what seemed like a reasonable approach - an extension to create italic fonts with…

Debugging an Xcodebuild hang, when the Swift compiler gets stuck

Building a complex iOS project with the Release scheme would hang indefinitely - no errors, no messages, just stuck. The Debug config worked fine but any Release configuration scheme would never complete. The build would appear to be running, but never finish. The Investigation Initial suspicion: circular dependencies between few local Swift packages that were shared among many other local…

AI sceptic in LLM adventure land

Ever since ChatGPT and its gen-AI ilk arrived, I have been very vocal and adamant that these are bullshit generators: they try to guess what you want and will continually hallucinate things until you say it’s OK. Depending on the body of existing knowledge they were trained on, they’ve becoming ever more successful in that endeavour. In the span of just few years and after countless energy spent…

Objective-C framework callbacks in Swift 6

After upgrading all my active projects to Swift 6 language mode, I was bound to encounter some head-scratching edge cases. One of the weirdest ones was this runtime crash: Thread 5 Queue : com.apple.root.default-qos (concurrent) #0 0x00000001021243f8 in _dispatch_assert_queue_fail () #1 0x0000000102124384 in dispatch_assert_queue () #2 0x00000002444c63e0 in swift_task_isCurrentExecutorImpl () #3…

Background (multipart) file upload from iOS app

Apple has great API for this purpose: URLSessionUploadTask . Almost at the very top, Apple says: Unlike data tasks, you can use upload tasks to upload content in the background. This is not by accident. File uploads are the least-loved feature of any app as no one wants to wait nor look at progress bars. Thus the proper way to do this is to encapsulate upload functionality into a module which is…

Stress-testing Core Data

I don’t think I wrote many apps in the last 10 years that did not involve Core Data. Apps without Core Data: have just a handful of screens with no shared data between them are demonstration / help type of app, basically a glorified user manual But if app has any kind of model graph / data shared across multiple views, I choose Core Data without hesitation. Its strengths are in handling of…

Strange issue adding SPM package as dependency on another package

Swift Package Manager dependency resolution mostly work logically: ① First you specify the dependency in any number of ways, here’s the most usual one: dependencies: [ .package( url: 'https://github.com/radianttap/Alley' , from: '3.0.0' ) , ② Then you reference dependent library by its product name: targets: [ .target( name: 'Atlas' , dependencies: [ 'Alley' ], Alley is simplest possible library -…

Hackintosh is (almost) dead

While I knew about and even tried various very early attempts to run macOS on non-Apple hardware, it wasn’t until early 2020 that I’ve built my first proper one. Then I built several more which are still seeing daily use. I explained my reasoning why it was worthwhile to attempt it. The technology was mostly there thanks to a group of dedicated hackers and timing was just right : But if ever there…

High-performance Core Data import

Let’s say you are writing an iOS client for Spotify’s API, specifically the search endpoint . Here you can get multiple entities, like Artist , Album , Track , Playlist and all of them are inter-related in that same JSON. You might get particular artist instance as top-level result and/or inside album.artists or even inside track.album.artists . It’s quite possible that one same artist can appear…

NSFRC’s sections considered harmful

Imagine a simple sports app model: League entity, with some id , name and displayOrder properties. It has a 1-many relationship to Event entity that has (among other attributes) id , name and of course — reverse to-one relationship back to League . You write a simple FetchRequest for FetchedResultsController when you are loading events grouped per league, with order defined by League.displayOrder…

Saving native Swift struct into Core Data's transformable attribute

When designing Core Data object graph, I spend copious amount of time thinking through each entity’s attributes and relationships. If I’m not careful, I can easily end-up with expansive graph containing many one-of leaf nodes. Analysing various graphs in the past, I noticed that many complex entities (even with dozen or so attributes) are really just a complex property of their 1-1 relationship…

Implement data detectors inside UILabel

UILabel has ability to render rather complex text through .attributtedText but is not user-interactive by default. Thus even though particular text can contain URLs or phone numbers, there is no native capability to tap on said URL and open a web view. Curiously, most open-source components that aim to enable this are years-old, written in Objective-C. Here’s how you can re-implement this feature…

Using NSFetchedResultsController’s diffable snapshot with UICollectionView’s diffable data source

Last several weeks, we ( Radiant Tap ) are working on a major app redesign for one of our clients. App is super-data-intensive, combining multiple different data sources into one complex bi-directional scrollable view. Here’s some samples of the design: Important bits what’s in there: First section is the horizontally scrollable set of ads, which are fetched from JSON file. Rarely changes but it…

Bitmask (bitwise) values in Core Data

OptionSet is great tool of the Swift language. It’s fantastic for modelling multi-option values like: blog tags, various kinds of flags and markers etc. Here’s a typical (for me) use case: customise cell design where content can have label and icon, might have a badge, maybe disclosure indicator, some kind of background view with or without shadow etc. You can either create a separate UICVCell…

Coordinator pattern with UITabBarController

Leonardo Maia Pugliese recently published a blog post that picked my interest: Coordinators and Tab Bars: A Love Story . I always love to read how other people employ this useful pattern thus I carefully read through it. The problem he is solving is this: Imagine that you have a tab bar with two tabs and each tab is a navigation controller. The Home Tab has 2 levels deep and the Orders Tab has 3…

Mac Studio is perfect Mac for app developers

Two years ago I lamented the gaping hole in the Apple’s desktop Mac lineup. I ended that post with: I would be perfectly happy to pay $3,000+ for a machine with that [16-ish core] CPU housed in Apple-designed case and cooling. If only Apple offered it. Few days ago, Apple released exactly what I asked for: Mac Studio is a very powerful workstation in 3.6L case . CPU can have up 10 (M1 Max)…

Async Operation for Core Data imports

I wrote about my Essentials snippers 4 years ago . I am still using them, slightly updated and modernised but they are still one of the first stops to choose what I need when I start a particular UIKit project. One advanced feature in there is AsyncOperation which a subclass of Operation which will not set itself to finished until the asynchronous task you give it is done. OperationQueue and…