Libraries

Pay it forward (2012 – 2025)

Throughout my years of development I’ve ended up building multiple reusable libraries. Those have prevented me from reinventing the wheel in every app, hopefully they can be useful for you as well!

While I haven’t settled on a predefined license like MIT or GPL3, I am currently looking for one that would have no restriction for indie developers but would prevent large tech companies from using them. If you know which one would be the best in the situation yet remain AppStore compatible I’m all ears!

Shush

Shush is your favorite librarian. Its goal is to make sure your simple data persistence needs are met.

Have you ever had a couple user preferences you’d like to sync without having to think (I know, I know) too much ? What about an array of the last 30 queries your user ran in your app ? Or some lightweight user generated data that you want persisted and synchronized using iCloud ?

Those are all handled easily, while trying its best to stay out of your way.

import Shush

extension NSNotification.Name {
    static let settingsChanged = NSNotification.Name("settings_changed")
}

struct Preferences {
    let shared = Preferences()

    @ShushValue(key: "using_dark_theme", defaultValue: false, notification: .settingsChanged)
    var usingDarkTheme: Bool
}

PPMGobbler

Simple image parser and encoder for PBM, PGM and PPM files, ASCII and binary variants are supported, bringing the full P1, P2, P3, P4, P5 and P6 support!

let imageData = try Data(contentsOf: URL(fileURLWithPath: "/path/to/my/image"))

// read RGB, grey levels or black and white image
let ppmImage = try PPMImage<PPMPixelRGB>(data: imageData)
let pgmImage = try PPMImage<PPMPixelGrey>(data: imageData)
let pbmImage = try PPMImage<PPMPixelBW>(data: imageData)

// Access pixels
let firstPixelRedValue = ppmImage[0, 0].r

// Display (UIImage and NSImage support is available)
myUIImageView.image = ppmImage.uiImage
myNSImageView.image = ppmImage.nsImage

SaneSwift

The brains behind Backlit. This package allows you to easily integrate SANE with the net backend into your own iOS app!

SaneSetLogLevel(0)
SaneLogger.externalLoggingMethod = { level, message in
    guard level >= .error else { return }
    print(message)
}

Sane.shared.configuration.hosts = [.init(hostname: "192.168.13.12", displayName: "My Server")]
Sane.shared.updateDevices { result in
    switch result {
    case .success(let devices):
        print("Found devices:", devices)

    case .failure(let error):
        print("Encountered error:", error)
    }
}

Disco

Swift library allowing various network features :

  • list the interfaces available on a device, including their IP and netmask
  • ping a whole interface, using its IP and netmask to list the possibly reachable IPs
  • use Bonjour and common service names to obtain a possible hostname for an IP address
  • check at regular intervals if a host is reachable on a specific port, for multiple pairs at a time

SYEmailHelper

Easily detect installed email clients and allow the user to choose one when sending an email.

I use it to quickly add a “Contact me” feature in my apps. This will detect a list of SYEmailService, representing:

  • native in-app composer
  • third party apps
  • last resort: copy email address to clipboard, to let your user send via an unsupported app

SYPictureMetadata

Read and write images metadata using ImageIO and easy to use models.

let metadata = try! SYMetadata(fileURL: imageURL)
metadata.metadataIPTC = metadata.metadataIPTC ?? SYMetadataIPTC()
metadata.metadataIPTC?.keywords  = ["Some test keywords", "added by SYMetadata example app"];
metadata.metadataIPTC?.city      = "Lyon";
metadata.metadataIPTC?.credit    = "© Me 2017";
    
let originalImageData = try! Data(contentsOf: imageURL)
let imageDataWithMetadata = try! metadata.apply(to: originalImageData)

SYOperationQueue

An operation queue subclass that allows LIFO style queuing and a max number of operations.

I made it to allow loading images in a large UICollectionView while scrolling. When set properly this will load images needed by the collection view even if the user scrolls, and loading first images needed quickly.