Swiftpack.co - ctreffs/SwiftNFD as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by ctreffs.
ctreffs/SwiftNFD 1.0.2
Swift wrapper for Native File Dialog, a tiny, neat C library that portably invokes native file open and save dialogs.
⭐️ 2
🕓 1 year ago
.package(url: "https://github.com/ctreffs/SwiftNFD.git", from: "1.0.2")

Swift Native File Dialog

license macOS Linux Windows

A thin Swift wrapper around the popular mlabbe/nativefiledialog library by Michael Labbe.

Native File Dialog is a tiny, neat C library that portably invokes native file open, folder select and save dialogs. Write dialog code once and have it pop up native dialogs on all supported platforms. Avoid linking large dependencies like wxWidgets and qt.


  • Zlib licensed.
  • Consistent UTF-8 support on all platforms.
  • Simple universal file filter syntax.
  • Multiple file selection support.
  • No third party dependencies for building or linking.
  • Support for Vista's modern IFileDialog on Windows.
  • Support for non-deprecated Cocoa APIs on OS X.
  • GTK3 dialog on Linux.
  • Tested, works alongside SDL2 on all platforms, for the game developers out there.


Single file dialog

// open single file dialog without filters
let result = NFD.OpenDialog()
switch result {
case let .success(path):
    if let path = path {
        // use path
    } else {
        // user canceled
case let .failure(error):
    // an error has occured

macOS Demo

You can find a macOS demo application in /Apps/NFD-Demo/NFD-Demo.xcodeproj


File Filter Syntax

There is a form of file filtering in every file dialog API, but no consistent means of supporting it. NFD provides support for filtering files by groups of extensions, providing its own descriptions (where applicable) for the extensions.

A wildcard filter is always added to every dialog.


txt The default filter is for text files. There is a wildcard option in a dropdown.

png,jpg;psd The default filter is for png and jpg files. A second filter is available for psd files. There is a wildcard option in a dropdown.

nil Wildcard only.

Copyright and Credit

Copyright © 2014-2019 Frogtoss Games, Inc. File LICENSE covers all files in this repo.

Native File Dialog by Michael Labbe [email protected]

Tomasz Konojacki for microutf8

Denis Kolodin for mingw support.

Tom Mason for Zenity support.


Directed support for this work is available from the original author under a paid agreement.

Contact Frogtoss Games.


Stars: 2
Last commit: 5 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1 year ago

Full Changelog: https://github.com/ctreffs/SwiftNFD/compare/1.0.1...1.0.2

  • Make gitmodule https based

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics