{"id":15723957,"url":"https://github.com/sebastianbaar/sbquicklook","last_synced_at":"2025-06-28T08:36:37.310Z","repository":{"id":81959415,"uuid":"605737537","full_name":"sebastianbaar/SBQuickLook","owner":"sebastianbaar","description":"Quickly preview local and remote files and their content using Apple's QuickLook Framework","archived":false,"fork":false,"pushed_at":"2023-02-26T14:28:27.000Z","size":74,"stargazers_count":15,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-19T22:43:53.586Z","etag":null,"topics":["ios","quicklook","spm","swift","swiftui","uikit"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebastianbaar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-23T19:48:15.000Z","updated_at":"2025-06-11T22:24:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"86691c6e-d5d8-49c1-a829-31d4c8e6a9b6","html_url":"https://github.com/sebastianbaar/SBQuickLook","commit_stats":{"total_commits":42,"total_committers":1,"mean_commits":42.0,"dds":0.0,"last_synced_commit":"cf6ab51c6ad9e1ab79418e8a5c20d5759ae335a3"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/sebastianbaar/SBQuickLook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastianbaar%2FSBQuickLook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastianbaar%2FSBQuickLook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastianbaar%2FSBQuickLook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastianbaar%2FSBQuickLook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebastianbaar","download_url":"https://codeload.github.com/sebastianbaar/SBQuickLook/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastianbaar%2FSBQuickLook/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262402398,"owners_count":23305655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","quicklook","spm","swift","swiftui","uikit"],"created_at":"2024-10-03T22:13:55.610Z","updated_at":"2025-06-28T08:36:37.249Z","avatar_url":"https://github.com/sebastianbaar.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SBQuickLook\n[![iOS Build](https://github.com/sebastianbaar/SBQuickLook/actions/workflows/ios.yml/badge.svg)](https://github.com/sebastianbaar/SBQuickLook/actions/workflows/ios.yml)\n[![Swift](https://github.com/sebastianbaar/SBQuickLook/actions/workflows/swiftlint.yml/badge.svg)](https://github.com/sebastianbaar/SBQuickLook/actions/workflows/swiftlint.yml)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fsebastianbaar%2FSBQuickLook%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/sebastianbaar/SBQuickLook)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fsebastianbaar%2FSBQuickLook%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/sebastianbaar/SBQuickLook)\n[![License](https://img.shields.io/badge/license-MIT-lightgrey.svg?longCache=true\u0026style=flat-square)](https://en.wikipedia.org/wiki/MIT_License)\n\nQuickly preview local \u0026 external files and their content using Apple's QuickLook Framework.\n\nThis package provides a wrapper around Apple's **[QuickLook Framework](https://developer.apple.com/documentation/quicklook)**. \n- Can preview:\n  - iWork and Microsoft Office documents\n  - Images\n  - Live Photos\n  - Text files\n  - PDFs\n  - Audio and video files\n  - Augmented reality objects that use the USDZ file format (iOS and iPadOS only)\n  - ZIP files\n  - ...\n- Can be used with **UIKit** or **SwiftUI**\n- Can be used to preview **one** or **multiple** files at once.\n- Can be used with **local file** URLs or **external** URLs (it also handels downloading the files).\n\n## 📦 Installation\n\nAdd this Swift package in Xcode using its Github repository url. (File \u003e Swift Packages \u003e Add Package Dependency...)\n\n## 🚀 How to use\n\nInitialize the View (SwiftUI) or ViewController (UIKit)\n\n```swift\n/// Initializes the `SBQuickLookView` or `SBQuickViewController` with the given file items and configuration.\n///\n/// - Parameters:\n///   - fileItems: The `[SBQLFileItem]` data for populating the preview. Could be one or many items.\n///   - configuration: Optional `SBQLConfiguration` configurations.\n///   - completion: Optional `Result\u003cSBQLError?, SBQLError\u003e` completion.\n///      - success: `QLPreviewController` successfully presented with at least one item. Optional `SBQLError` if some items failed to download.\n///      - failure: `QLPreviewController` could not be  presented.\npublic init(\n    fileItems: [SBQLFileItem],\n    configuration: SBQLConfiguration? = nil,\n    completion: ((Result\u003cSBQLError?, SBQLError\u003e) -\u003e Void)? = nil) {\n        self.fileItems = fileItems\n        self.configuration = configuration\n        self.completion = completion\n    }\n```\n\nYou have to pass the file items `SBFileItem` to the initializer. Either pass one item or multiple items to the View (SwiftUI) or ViewController (UIKit).\n\n```swift\n/// Initializes the file item with the given values.\n///\n/// - Parameters:\n///   - url: `URL` of the item, choose between local file URLs or external URLs\n///   - title: Optional title `String` to be displayed in the QuickLook controller.\n///   - content: Optional media type `String` of the file; e.g. `\"pdf\"`, `\"jpeg\"`, ...\n///   - urlRequest: Optional `URLRequest` used to download the item. The `url` is always set to `fileItem.url`. Default: `URLRequest(url: fileItem.url)`\npublic init(url: URL, title: String? = nil, mediaType: String? = nil, urlRequest: URLRequest? = nil) {\n    self.url = url\n    self.title = title\n    self.mediaType = mediaType\n    self.urlRequest = urlRequest\n}\n```\n\nYou can also pass an optional `SBQLConfiguration` to the initializer.\n\n```swift\n/// Initializes the file item with the given values.\n///\n/// - Parameters:\n///   - urlRequest: Optional `URLSession`. Overrides the `URLSession` used by the download task. Default: `URLSession.shared`\n///   - localFileDir: Optional local directory `URL`. Overrides the local directory `URL` used by the download task. Default: `FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)`\npublic init(session: URLSession? = nil, localFileDir: URL? = nil) {\n    self.session = session\n    self.localFileDir = localFileDir\n}\n```\n\n### SwiftUI\nPresent the `SBQuickLookView` (which is a `UIViewControllerRepresentable` wrapper for the `SBQuickViewController`) from your favorite View.\n\n```swift\n@State var isShown = false\n\nlet fileItems: [SBFileItem]\nlet configuration: SBQLConfiguration\n\ninit() {\n    let localFileURL = Bundle.main.url(forResource: \"sample-local-pdf\", withExtension: \"pdf\")!\n    \n    fileItems = [\n        SBFileItem(url: localFileURL, title: \"LOCAL FILE\"),\n        SBFileItem(url: URL(string: \"https://file-examples.com/storage/fe197d899c63f609e194cb1/2017/10/file_example_PNG_500kB.png\")!, title: \"Nice PNG Image\", mediaType: \"png\")\n    ]\n    \n    let localFileDir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!\n    configuration = SBQLConfiguration(localFileDir: localFileDir)\n}\n\nvar body: some View {\n    VStack {            \n        Button {\n            isShown.toggle()\n        } label: {\n            Text(\"Open QuickLook of files\")\n        }\n    }\n    .fullScreenCover(isPresented: $isShown, content: {\n        SBQuickLookView(fileItems: fileItems, configuration: configuration) { result in\n            switch result {\n            case .success(let downloadError):\n                if let downloadError {\n                    print(downloadError)\n                }\n            case .failure(let error):\n                switch error.type {\n                case .emptyFileItems:\n                    print(\"emptyFileItems\")\n                case .qlPreviewControllerError:\n                    print(\"qlPreviewControllerError\")\n                case .download(let errorFileItems):\n                    print(\"all items failed downloading\")\n                    print(errorFileItems)\n                }\n            }\n        }\n    })        \n}\n``` \n\n### UIKit \nPresent the `SBQuickViewController` from your favorite ViewController.\n\n```swift\nlet localFileURL = Bundle.main.url(forResource: \"sample-local-pdf\", withExtension: \"pdf\")!\n\nlet fileItems = [\n    SBFileItem(url: localFileURL, title: \"LOCAL FILE\"),\n    SBFileItem(url: URL(string: \"https://file-examples.com/storage/fe197d899c63f609e194cb1/2017/10/file_example_PNG_500kB.png\")!, title: \"Nice PNG Image\", mediaType: \"png\")\n]\n\nlet localFileDir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!\nlet configuration = SBQLConfiguration(localFileDir: localFileDir)\n\nlet qlController = SBQuickViewController(fileItems: fileItems, configuration: configuration)\nqlController.modalPresentationStyle = .overFullScreen\npresent(qlController, animated: true)\n```\n\n## 🎓 Example\n\nExample SwiftUI Project can be found [here](https://github.com/sebastianbaar/SBQuickLook-Example/tree/main).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastianbaar%2Fsbquicklook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebastianbaar%2Fsbquicklook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastianbaar%2Fsbquicklook/lists"}