{"id":1127,"url":"https://github.com/amosavian/AMSMB2","last_synced_at":"2025-07-30T20:31:12.612Z","repository":{"id":38360999,"uuid":"134099823","full_name":"amosavian/AMSMB2","owner":"amosavian","description":"Swift framework to connect SMB2/3 shares","archived":false,"fork":false,"pushed_at":"2025-07-08T20:35:15.000Z","size":39182,"stargazers_count":278,"open_issues_count":12,"forks_count":85,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-07-08T21:36:48.154Z","etag":null,"topics":["ios","smb","smb2","smb3","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amosavian.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,"zenodo":null}},"created_at":"2018-05-19T21:40:16.000Z","updated_at":"2025-07-08T20:35:18.000Z","dependencies_parsed_at":"2023-11-21T21:29:58.351Z","dependency_job_id":"3b5c3119-5eb6-45d5-98ea-3a3fe73257cb","html_url":"https://github.com/amosavian/AMSMB2","commit_stats":{"total_commits":97,"total_committers":7,"mean_commits":"13.857142857142858","dds":0.09278350515463918,"last_synced_commit":"4394c4db8e28211e999b87e5d16858dc2db607b2"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"purl":"pkg:github/amosavian/AMSMB2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amosavian%2FAMSMB2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amosavian%2FAMSMB2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amosavian%2FAMSMB2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amosavian%2FAMSMB2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amosavian","download_url":"https://codeload.github.com/amosavian/AMSMB2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amosavian%2FAMSMB2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267935263,"owners_count":24168290,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","smb","smb2","smb3","swift"],"created_at":"2024-01-05T20:15:39.480Z","updated_at":"2025-07-30T20:31:12.329Z","avatar_url":"https://github.com/amosavian.png","language":"Swift","funding_links":[],"categories":["Files"],"sub_categories":["Getting Started","Linter"],"readme":"# AMSMB2\n\n\nThis is small Swift library for iOS, macOS and tvOS which wraps [libsmb2](https://github.com/sahlberg/libsmb2) and allows to connect a SMB2/3 share and do file operation.\n\n[![Swift Version Compatibility][swift-version-image]][swift-version-url]\n[![Platform Compatibility ][platform-image]][platform-url]\n[![License][license-image]][license-url]\n[![Release version][release-image]][release-url]\n\n\n## Getting Started\n\nTo use AMSMB2, add the following dependency to your Package.swift:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/amosavian/AMSMB2\", .upToNextMinor(from: \"3.0.0\"))\n]\n```\n\nYou can then add the specific product dependency to your target:\n\n```swift\ndependencies: [\n    .product(name: \"AMSMB2\", package: \"AMSMB2\"),\n]\n```\n\n## Usage\n\nJust read inline help to find what each function does. It's straightforward. It's thread safe.\n\nTo do listing files in directory and file operations you must use this template:\n\n```swift\nimport AMSMB2\n\nclass SMBClient: @unchecked Sendable {\n    /// connect to: `smb://guest@XXX.XXX.XX.XX/share`\n    \n    let serverURL = URL(string: \"smb://XXX.XXX.XX.XX\")!\n    let credential = URLCredential(user: \"guest\", password: \"\", persistence: URLCredential.Persistence.forSession)\n    let share = \"share\"\n    \n    lazy private var client = SMB2Manager(url: self.serverURL, credential: self.credential)!\n    \n    private func connect() async throws -\u003e SMB2Manager {\n        // AMSMB2 can handle queueing connection requests\n        try await client.connectShare(name: self.share)\n        return self.client\n    }\n    \n    func listDirectory(path: String) {\n        Task {\n            do {\n                let client = try await connect()\n                let files = try await client.contentsOfDirectory(atPath: path)\n                for entry in files {\n                    print(\n                        \"name:\", entry[.nameKey] as! String,\n                        \", path:\", entry[.pathKey] as! String,\n                        \", type:\", entry[.fileResourceTypeKey] as! URLFileResourceType,\n                        \", size:\", entry[.fileSizeKey] as! Int64,\n                        \", modified:\", entry[.contentModificationDateKey] as! Date,\n                        \", created:\", entry[.creationDateKey] as! Date)\n                }\n            } catch {\n                print(error)\n            }\n        }\n    }\n    \n    func moveItem(path: String, to toPath: String) {\n        Task {\n            do {\n                let client = try await self.connect()\n                try await client.moveItem(atPath: path, toPath: toPath)\n                print(\"\\(path) moved successfully.\")\n                \n                // Disconnecting is optional, it will be called eventually\n                // when `AMSMB2` object is freed.\n                // You may call it explicitly to detect errors.\n                try await client.disconnectShare()\n            } catch {\n                print(error)\n            }\n        }\n    }\n}\n\n```\n\n## License\n\nWhile source code shipped with project is MIT licensed, but it has static link to `libsmb2` which is `LGPL v2.1`, consequently the whole project becomes `LGPL v2.1`.\n\nYou **must** link this library dynamically to your app if you intend to distribute your app on App Store.\n\n[swift-version-image]: https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Famosavian%2FAMSMB2%2Fbadge%3Ftype%3Dswift-versions\n[swift-version-url]: https://swiftpackageindex.com/amosavian/AMSMB2\n[platform-image]: https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Famosavian%2FAMSMB2%2Fbadge%3Ftype%3Dplatforms\n[platform-url]: https://swiftpackageindex.com/amosavian/AMSMB2\n[license-image]: https://img.shields.io/github/license/amosavian/AMSMB2.svg\n[license-url]: LICENSE\n[release-image]: https://img.shields.io/github/release/amosavian/AMSMB2.svg\n[release-url]: https://github.com/amosavian/AMSMB2/releases\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famosavian%2FAMSMB2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famosavian%2FAMSMB2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famosavian%2FAMSMB2/lists"}