Swiftpack.co -  markrenaud/FilePicker as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
markrenaud/FilePicker
An easy-to-use cross platform file picker for SwiftUI.
.package(url: "https://github.com/markrenaud/FilePicker.git", from: "1.0.1")

FilePicker

A cross platform file picker for SwiftUI.

License

The FilePicker package implements a SwiftUI view that can be used in both iOS and macOS. The FilePicker provides a Button that presents a platform-native file picker that is a modern way for use in SwiftUI.

Installation

Add the FilePicker package to your Xcode project using the package manager. Import FilePicker to your file.

If you are using the package with macOS, ensure that you grant appropriate File Access permissions for User Selected File under Signing & Capabilities (on the macOS target)

Example Usage

import SwiftUI
import FilePicker

struct DebugView: View {
    
    var body: some View {
        HStack {
            //  
        
            // Use custom content for the button label
            FilePicker(types: [.plainText], allowMultiple: true) { urls in
                print("selected \(urls.count) files")
            } label: {
                HStack {
                    Image(systemName: "doc.on.doc")
                    Text("Pick Files")
                }
            }
            
            FilePicker(types: [.plainText], allowMultiple: false, title: "pick single file") { urls in
                print("selected \(urls.count) files")
            }
            
        }
    }
    
}

Licence

Distributed under the MIT license. See LICENSE for more information.

GitHub

link
Stars: 0
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Related Packages

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