Swiftpack.co - Package - SDGGiesbrecht/SDGInterface

macOS • Windows • Web • CentOS • Ubuntu • tvOS • iOS • Android • Amazon Linux • watchOS



SDGInterface provides tools for implementing a graphical user interface.

Καὶ ὁ Λόγος σὰρξ ἐγένετο καὶ ἐσκήνωσεν ἐν ἡμῖν, καὶ ἐθεασάμεθα τὴν δόξαν αὐτοῦ, δόξαν ὡς μονογενοῦς παρὰ πατρός, πλήρης χάριτος καὶ ἀληθείας.

And the Word became flesh and dwelt among us and we have watched His glory, the glory of the Only Begotten of the Father, full of grace and truth.



  • API unification accross platforms.
  • Localized menu bar.

Example Usage

import Foundation

import SDGText
import SDGLocalization

import SDGTextDisplay
import SDGWindows
import SDGApplication

public struct SampleApplication: SDGApplication.Application {

  public init() {}

  public var applicationName: ProcessInfo.ApplicationNameResolver {
    return { form in
      switch form {
      case .english(let region):
        switch region {
        case .unitedKingdom, .unitedStates, .canada:
          return "Sample"
      case .español(let preposición):
        switch preposición {
        case .ninguna:
          return "Ejemplar"
        case .de:
          return "del Ejemplar"
      case .deutsch(let fall):
        switch fall {
        case .nominativ, .akkusativ, .dativ:
          return "Beispiel"
      case .français(let préposition):
        switch préposition {
        case .aucune:
          return "Exemple"
        case .de:
          return "de l’Exemple"

      case .ελληνικά(let πτώση):
        switch πτώση {
        case .ονομαστική:
          return "Παράδειγμα"
        case .αιτιατική:
          return "το Παράδειγμα"
        case .γενική:
          return "του Παραδείγματος"
      case .עברית:
        return "דוגמה"

  public func finishLaunching(_ details: LaunchDetails) -> Bool {
    Swift.print("Hello, world!")
    return true
@main extension SampleApplication {}


SDGInterface provides libraries for use with the Swift Package Manager.

Simply add SDGInterface as a dependency in Package.swift and specify which of the libraries to use:

let package = Package(
  name: "MyPackage",
  dependencies: [
      name: "SDGInterface",
      url: "https://github.com/SDGGiesbrecht/SDGInterface",
      .upToNextMinor(from: Version(0, 9, 0))
  targets: [
      name: "MyTarget",
      dependencies: [
        .product(name: "SDGApplication", package: "SDGInterface"),
        .product(name: "SDGMenuBar", package: "SDGInterface"),
        .product(name: "SDGContextMenu", package: "SDGInterface"),
        .product(name: "SDGErrorMessages", package: "SDGInterface"),
        .product(name: "SDGMenus", package: "SDGInterface"),
        .product(name: "SDGPopOvers", package: "SDGInterface"),
        .product(name: "SDGWindows", package: "SDGInterface"),
        .product(name: "SDGTables", package: "SDGInterface"),
        .product(name: "SDGProgressIndicators", package: "SDGInterface"),
        .product(name: "SDGButtons", package: "SDGInterface"),
        .product(name: "SDGImageDisplay", package: "SDGInterface"),
        .product(name: "SDGTextDisplay", package: "SDGInterface"),
        .product(name: "SDGViews", package: "SDGInterface"),
        .product(name: "SDGViewsTestUtilities", package: "SDGInterface"),
        .product(name: "SDGKeyboard", package: "SDGInterface"),
        .product(name: "SDGInterfaceBasics", package: "SDGInterface"),

The modules can then be imported in source files:

import SDGApplication
import SDGMenuBar
import SDGContextMenu
import SDGErrorMessages
import SDGMenus
import SDGPopOvers
import SDGWindows
import SDGTables
import SDGProgressIndicators
import SDGButtons
import SDGImageDisplay
import SDGTextDisplay
import SDGViews
import SDGViewsTestUtilities
import SDGKeyboard
import SDGInterfaceBasics


The SDGInterface project is maintained by Jeremy David Giesbrecht.

If SDGInterface saves you money, consider giving some of it as a donation.

If SDGInterface saves you time, consider devoting some of it to contributing back to the project.

Ἄξιος γὰρ ὁ ἐργάτης τοῦ μισθοῦ αὐτοῦ ἐστι.

For the worker is worthy of his wages.



Stars: 3


Used By

Total: 0


Version 0.9.0 -

Breaking Changes

  • Swift 5.3
  • More views have been converted to a SwiftUI‐style API:
    • Button
    • Colour
    • ContextMenu
    • CheckBox
    • Image
    • Label
    • LabelledProgressBar
    • LabelledTextField
    • Log
    • ProgressBar
    • SegmentedControl
    • Table
    • TextEditor
    • TextField
    • TextView
  • Other types have also been converted to a SwiftUI‐style API:
    • Menu
    • MenuEntry
    • .popOver(...)
    • Window

New Features

  • CentOS and Amazon Linux have support comparable to Ubuntu.

Version 0.8.0 -

Breaking Changes

  • Swift 5.2
  • HorizontalStack is now generic. Heterogenous stacks require using AnyView.
  • SpecificView has been removed.
  • Many properties and parameters named native have been renamed to cocoa, swiftUI, foundation or the like to specify which kind of “native”.

New Features

  • A ViewsTestUtilities module is available to help test View conformances.

Bug Fixes

  • Several declarations with @objc are no longer disabled on Windows, because the Swift 5.2 compiler can now handle them.

Version 0.7.0 -

Breaking Changes

  • To make View generic and improve SwiftUI performance, it has been split in two, with LegacyView covering the functionality available without SwiftUI.
    • Existential uses that could not be made generic now use the new AnyView wrapper.
    • Properties have been converted to methods to make it clearer that the representation is constructed on demand, not stored.
      • swiftUIViewswiftUI()
      • cocoaViewcocoa()
  • CocoaView is now used in many places to bridge the differences between NSView and UIView.
  • Functionality of AnyCocoaView has been moved to CocoaView.
    • Layout constraint APIs have been updated.
  • Spacing has been removed in favour of Double?. .automatic is replaced by nil.
  • StabilizedView has been removed as it is no longer meaningful. (CocoaView is stable, and is the type used in the API of methods that require stability.)
  • letterboxed(aspectRatio:background:) has been renamed to letterbox(aspectRation:background).

New Features

  • Web is now supported (as a platform). Actual runtime stability depends on the toolchain used to compile the package.

Bug Fixes

  • EmptyView is available back to watchOS 6.

Version 0.6.0 -

Breaking Changes

  • A View is no longer assumed to be a Cocoa view in need of a SwiftUI wrapper. Such views should now declare a conformance to CocoaViewImplementation to get the default wrapper.
  • SwiftUIView has been removed. SwiftUI views no longer need to be wrapped; they should conform to View directly. This is as simple as declaring a conformance to SwiftUIViewImplementation.
  • To align with View.cocoaView,
    • SpecificView.specificNative has been renamed to .specificCocoaView.
    • AnyNativeView has been renamed to AnyCocoaView.
  • Many protocols—most notably View—no longer inherit from AnyObject, so that structures can be used.
  • Parts of the API have shifted to a style more like SwiftUI and less like Cocoa.
    • lockAspectRatio(to:)aspectRatio(_:contentMode:)
    • Letterboxletterboxed(aspectRatio:background:)
    • MarginViewpadding(_:_:)
    • RowViewHorizontalStack

New Features

  • Windows and Android have support comparable to Linux. Actual runtime stability depends on the toolchain used to compile the package.
  • Several of the view‐related protocols are now available on watchOS.

Version 0.5.0 -

Breaking Changes

  • View.native has been renamed to View.cocoaView to contrast against swiftUIView.
  • Font.resized(to:) has been dropped. It has been sunk into SDGCornerstone’s SDGText instead.

New Features

  • SwiftUI‐related features are available on iOS.
  • All views can be incorporated into SwiftUI hierarchies via their swiftUIView property.

Version 0.4.0 -

Breaking Changes

  • Swift 5.1
  • alignFirstBaselines(ofSubviews:) has been removed in favour of alignLastBaselines(ofSubviews:) for compatibility with older platforms.

New Features

  • All platform restrictions have been dropped.
  • Wrappers are available for incorporating SwiftUI into View hierarchies.
  • Progress indicators are available.

Bug Fixes

  • Bundle validation verifies that NSAppleEventsUsageDescription is localized if present.

Version 0.3.1 -

New Features

  • Interface elements are localized into German.
  • CoreGraphics key codes are available on all platforms.

Bug Fixes

  • Bundle validation checks for the localized name flag.
  • Bundle validation checks Info.plist against the fallback localization’s InfoPlist.strings file.

Version 0.3.0 -

Breaking Changes

  • More types have been moved out of SDGInterfaceElements into specialized modules.
  • More alias pairs have been replaced with encapsulating types.

Version 0.2.1 -

New Features

  • TextFields have a bindable text value.
  • Windows have a closeAction that will be executed when the window closes.

Bug Fixes

  • Changing the sort order causes Table views to refresh.

Version 0.2.0 -

Breaking Changes

  • Many types have been moved out of SDGInterfaceElements into specialized modules.
  • Many alias pairs have been replaced with encapsulating types.
  • Sections of the API have been restricted to platforms where they are meaningful.

New Features

  • SDGInterface can be used on Linux, although large portions of the API are unavailable.

Version 0.1.0 -

Initial release.