Short answer

Nine iOS notes from September 2019, checked again: safe area insets are zero in viewDidLoad, so pin to the safe area layout guide; swipe actions with UIContextualAction (UITableViewRowAction is deprecated); the String? to NSString error; two CocoaPods-era build errors and the Xcode 14 change that removed one old fix; a Realm schema version crash and the migration that prevents it; hiding the cursor; photo library permission with the iOS 14 .limited case; and placeholder colors, including the KVC trick that crashes since iOS 13.

SWIFT TIPS · UIKIT · 9 NOTES

First posted on September 29, 2019, as "9 Notes in September Swift 5.1". Rewritten on November 19, 2026. The tests were run as Mac Catalyst programs with Swift 6.2.3 (Xcode 26.2, Swift 5 mode) on macOS 26.0.1, and every code block was type-checked for an iOS 15 target, except the Realm snippet, which I didn't compile because Realm isn't installed here. No photo library permission was requested. Nothing was run on an iPhone or a simulator.

September 2019 was the month Xcode 11 and iOS 13 came out, and the notes are a mix of new APIs and old errors: swipe actions, safe areas, two build failures, a Realm crash, a permission check and some text field styling. Several notes were just an error message and a link.

For each, this rewrite gives the cause, the current fix and a test where I could run one. Four of the errors are reproduced below with today's compiler, so you can match the message you're seeing.

1. A view as tall as the safe area

2019: set a height constraint's constant to view.safeAreaInsets.top, or .left, .right or .bottom.

Now: it works only if you read the value at the right time. In viewDidLoad the view isn't in a window yet, so the insets are zero:

safeAreaInsets.top read in viewDidLoad: 0.0

A constant copied then stays zero, and it also goes stale on rotation or in Split View. I tried to show the inset changing by putting the view controller in a window, but a command-line Mac Catalyst program can't create one, so the rest of this note is from Apple's documentation, not from my test. Pinning to safeAreaLayoutGuide needs no number at all and follows every change; when you do need the number, viewSafeAreaInsetsDidChange() is called each time it changes:

import UIKit

final class ProfileViewController: UIViewController {
    let header = UIView()
    private var headerHeight: NSLayoutConstraint!

    override func viewDidLoad() {
        super.viewDidLoad()
        header.translatesAutoresizingMaskIntoConstraints = false
        view.addSubview(header)
        // Option 1: pin to the safe area guide. It updates itself on rotation and in split view.
        NSLayoutConstraint.activate([
            header.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
            header.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            header.trailingAnchor.constraint(equalTo: view.trailingAnchor)
        ])
        headerHeight = header.heightAnchor.constraint(equalToConstant: 44)
        headerHeight.isActive = true
    }

    // Option 2: when you need the number itself, read it when it changes, not in viewDidLoad.
    override func viewSafeAreaInsetsDidChange() {
        super.viewSafeAreaInsetsDidChange()
        print("top inset is now", view.safeAreaInsets.top)
    }
}

2. Swipe actions on table view cells

2019: three options: commit editingStyle for delete and insert, editActionsForRowAt returning UITableViewRowAction buttons with text, and trailingSwipeActionsConfigurationForRowAt with UIContextualAction for buttons with images.

Now: the second option is deprecated:

SwipeActions.swift:2:20: warning: 'UITableViewRowAction' was deprecated in iOS 13.0: Use UIContextualAction and related APIs instead.

The third option, available since iOS 11, does everything the other two did: text, images, colors, both sides of the cell, and a full swipe. This version has Delete and Flag on the right and Read on the left:

import UIKit

final class InboxViewController: UITableViewController {
    var messages = ["Welcome", "Invoice", "Meeting"]

    override func tableView(_ tableView: UITableView,
                            trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath)
        -> UISwipeActionsConfiguration? {
        let delete = UIContextualAction(style: .destructive, title: "Delete") { [weak self] _, _, done in
            self?.messages.remove(at: indexPath.row)
            tableView.deleteRows(at: [indexPath], with: .automatic)
            done(true)
        }
        let flag = UIContextualAction(style: .normal, title: "Flag") { _, _, done in
            done(true)
        }
        flag.image = UIImage(systemName: "flag")
        flag.backgroundColor = .systemOrange
        return UISwipeActionsConfiguration(actions: [delete, flag])  // full swipe runs Delete
    }

    override func tableView(_ tableView: UITableView,
                            leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath)
        -> UISwipeActionsConfiguration? {
        let read = UIContextualAction(style: .normal, title: "Read") { _, _, done in done(true) }
        read.image = UIImage(systemName: "envelope.open")
        read.backgroundColor = .systemBlue
        let configuration = UISwipeActionsConfiguration(actions: [read])
        configuration.performsFirstActionWithFullSwipe = false
        return configuration
    }
}
actions: ["Delete", "Flag"] | full swipe runs the first action: true | Flag has an image: true
after setting it to false: false

A full swipe runs the first action by default, which is why Delete comes first on the right; turn it off for actions that shouldn't fire by accident. Call the completion handler with true when the action succeeded, so the row closes. commit editingStyle still works for the classic red Delete button in edit mode.

3. "'String?' is not convertible to 'NSString'"

2019: text.name as NSString failed because name was optional; the fix was "\(text.name ?? "")" as NSString.

Now: the same error, with a suggestion you shouldn't take:

NameLength.swift:4:26: error: 'String?' is not convertible to 'NSString'
NameLength.swift:4:26: note: did you mean to use 'as!' to force downcast?

as! crashes when the name is nil. The 2019 fix was safe; the string interpolation around it just isn't needed. (text.name ?? "") as NSString does the same. People reach for NSString for its length and NSRange methods, and the test shows why that length differs from Swift's count:

NSString length (UTF-16 units): 7 | Swift count (characters): 6
nil name -> "" length 0

An emoji is one character to Swift but two UTF-16 units to NSString. Use length when you build an NSRange, and count when you mean characters as people see them.

4. "Unable to load contents of file list: '.../Info.plist'"

2019: a link to the Stack Overflow question for this build error.

Now: this came from CocoaPods projects at the time Xcode 10's new build system arrived: the build phases CocoaPods adds refer to file lists that weren't there. The accepted answer on that question deintegrates CocoaPods, cleans and installs again; it also installs gems with sudo, which I wouldn't do, since it writes into the system Ruby. A version manager or Homebrew Ruby avoids that. In short:

gem install cocoapods      # in a Ruby you own, not with sudo
pod deintegrate
pod install

Then open the .xcworkspace, not the .xcodeproj. One more thing worth knowing in late 2026: the CocoaPods team plans to make the trunk spec repo read-only, planned for December 2, 2026, though their post says the dates may change. Existing pods keep installing, but no new versions will arrive through trunk, so new projects are better started with Swift Package Manager.

5. Realm: "Provided schema version 2 is less than last set version 42"

2019: delete the app from the simulator or device and run again, because I changed the database schema without a migration, quoting a Rocket.Chat issue.

Now: deleting the app is fine on your own simulator; it removes the database file. For people who already have the app, it means losing their data, so a release needs a migration. Raise schemaVersion every time a model changes, and never lower it, which is what the error is about: the file on disk was written with version 42 and the code asked for 2. I didn't compile this, since Realm isn't installed here; the parameter names are from realm-swift's RealmConfiguration.swift:

let config = Realm.Configuration(
    schemaVersion: 43,
    migrationBlock: { migration, oldVersion in
        if oldVersion < 43 {
            // Fill in new properties or rename old ones here.
        }
    })
Realm.Configuration.defaultConfiguration = config

// During development only: start over instead of migrating.
// Realm.Configuration(schemaVersion: 43, deleteRealmIfMigrationNeeded: true)

Set the configuration before the first try! Realm() anywhere in the app, usually at launch. Adding and removing properties is handled automatically once the version goes up; the block is for changes Realm can't guess, like renaming.

6. "Build input file cannot be found"

2019: the file is missing from the project or listed twice; two Stack Overflow links; and if the project has a "Recovered References" group, delete the missing files in it.

Now: the cause is the same: the project still lists a file that isn't on disk, often after a merge or after moving files in Finder instead of in Xcode. Missing files show in red in the project navigator. Select the target, open Build Phases, and remove the red entries from Compile Sources and Copy Bundle Resources, then add the file back from its new place if you still need it. A "Recovered References" group holds file references that lost their parent group, which developers usually report after a badly merged project file; the red files in it are safe to remove.

The other top answer on that question, switching to the Legacy Build System, no longer exists as an option: Xcode 14's release notes say the legacy build system has been removed.

7. Hide the blinking cursor

2019: textField.tintColor = UIColor.clear, or a tint the same as the background.

Now: that works, but the tint also colors the text selection, so selecting text in that field shows nothing either. A subclass that returns an empty caret rectangle hides only the cursor:

import UIKit

/// A text field for picker-style input: no blinking cursor, no selection handles.
final class NoCaretTextField: UITextField {
    override func caretRect(for position: UITextPosition) -> CGRect { .zero }

    override func selectionRects(for range: UITextRange) -> [UITextSelectionRect] { [] }

    override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
        action == #selector(copy(_:)) ? super.canPerformAction(action, withSender: sender) : false
    }
}
normal caret rect: (1.0, 21.5)
NoCaretTextField caret rect: (0.0, 0.0)
2019 fix, tintColor = .clear: true

The normal field's caret was 1 point wide; the subclass's was zero. This one also hides selection and allows only Copy in the menu, which suits a field that opens a picker and shouldn't look editable. Remember that the field still accepts focus, so VoiceOver users can reach it.

8. Check photo library permission

2019: a switch on PHPhotoLibrary.authorizationStatus() with four cases.

Now: iOS 14 added a fifth status, and the 2019 switch no longer compiles:

Permission.swift:4:5: error: switch must be exhaustive
Permission.swift:4:5: note: add missing case: '.limited'
Permission.swift:4:5: note: handle unknown values using "@unknown default"
Permission.swift:4:5: note: add missing cases

.limited means the person shared only some photos. The iOS 26 SDK also marks the method without an argument as to be deprecated, with authorizationStatus(for:) as the replacement, where you say whether you need read and write or add-only access:

import Photos

enum PhotoAccess { case full, limited, denied, notAsked }

func currentPhotoAccess() -> PhotoAccess {
    switch PHPhotoLibrary.authorizationStatus(for: .readWrite) {
    case .authorized: return .full
    case .limited: return .limited          // iOS 14: the person picked some photos only
    case .denied, .restricted: return .denied
    case .notDetermined: return .notAsked
    @unknown default: return .denied
    }
}

func requestPhotoAccess() async -> PhotoAccess {
    _ = await PHPhotoLibrary.requestAuthorization(for: .readWrite)
    return currentPhotoAccess()
}

If you only need the person to pick a photo, PHPickerViewController needs no permission at all, so you can skip this whole check. If you only save photos, ask for .addOnly.

9. Placeholder text color

2019: set attributedPlaceholder with a .foregroundColor, or set placeholderLabel.textColor as a runtime attribute in the xib.

Now: attributedPlaceholder is the supported way:

import UIKit

@MainActor
func setPlaceholder(_ text: String, color: UIColor, on field: UITextField) {
    field.attributedPlaceholder = NSAttributedString(string: text, attributes: [.foregroundColor: color])
}

// setPlaceholder("Min. Rp 50.000", color: .secondaryLabel, on: amountTextField)
placeholder: Min. Rp 50.000 | color is secondaryLabel: true

Two cases need keeping apart for the runtime attribute. In the 2019 screenshot below, placeholderLabel sits next to activeLineColor and lineWidth, so that field was a custom text field class with its own public placeholderLabel property; setting it there is fine. On a plain UITextField, though, a well-known trick was the private key path _placeholderLabel.textColor, and since iOS 13 that crashes. I reproduced it:

Calling field.setValue(UIColor.white, forKeyPath: "_placeholderLabel.textColor") ...
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Access to UITextField's _placeholderLabel ivar is prohibited. This is an application bug'

If you find _placeholderLabel in an old project, in code or under User Defined Runtime Attributes, replace it with attributedPlaceholder.

What the 2019 version said

The post had four screenshots, for notes 3, 6, 7 and 9:

Xcode error: String? is not convertible to NSString; did you mean to use as! to force downcast?

Project navigator with a Recovered References group below ShareAssets.xcassets

Attributes inspector with Tint set to Primary, the setting for the cursor color

User Defined Runtime Attributes of a custom text field: activeLineWidth, activeLineColor, lineWidth, lineColor and placeholderLabel.textColor

Sources