Go to file
renovate[bot] 9551561513
Update dependency nicklockwood/SwiftFormat to v0.51.10 (#18)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-25 08:45:53 +02:00
.github Update ci-windows.yml (#13) 2023-04-19 08:52:15 +02:00
3rdparty Use NFD extended 2021-11-05 07:01:59 +01:00
Apps/NFD-Demo Add CI (#1) 2021-11-05 13:35:51 +01:00
Resources Update README 2021-11-05 11:36:22 +01:00
Sources Fix result 2021-11-05 14:35:20 +01:00
.gitignore Init package 2021-11-05 06:35:45 +01:00
.gitmodules Fix gitmodule 2021-11-06 07:19:18 +01:00
.swiftformat Make releasable 2021-11-05 09:59:06 +01:00
.swiftlint.yml Make releasable 2021-11-05 09:59:06 +01:00
CODEOWNERS GitHub files 2021-11-05 13:38:50 +01:00
CODE_OF_CONDUCT.md GitHub files 2021-11-05 13:38:50 +01:00
CONTRIBUTING.md GitHub files 2021-11-05 13:38:50 +01:00
LICENSE Add LICENSE 2021-11-05 11:40:03 +01:00
Makefile Add CI (#1) 2021-11-05 13:35:51 +01:00
Mintfile Update dependency nicklockwood/SwiftFormat to v0.51.10 (#18) 2023-05-25 08:45:53 +02:00
Package.swift Add CI (#1) 2021-11-05 13:35:51 +01:00
README.md Add CI (#1) 2021-11-05 13:35:51 +01:00
renovate.json Update renovate.json 2023-04-18 09:32:31 +02:00

README.md

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.

Features:

  • 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.

Usage

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

NFD-Demo

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.

Examples

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 mike@frogtoss.com

Tomasz Konojacki for microutf8

Denis Kolodin for mingw support.

Tom Mason for Zenity support.

Support

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

Contact Frogtoss Games.