Net.MAUILibrary.iOS.AMSMB2Interop 4.0.3

dotnet add package Net.MAUILibrary.iOS.AMSMB2Interop --version 4.0.3
                    
NuGet\Install-Package Net.MAUILibrary.iOS.AMSMB2Interop -Version 4.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Net.MAUILibrary.iOS.AMSMB2Interop" Version="4.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Net.MAUILibrary.iOS.AMSMB2Interop" Version="4.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Net.MAUILibrary.iOS.AMSMB2Interop" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Net.MAUILibrary.iOS.AMSMB2Interop --version 4.0.3
                    
#r "nuget: Net.MAUILibrary.iOS.AMSMB2Interop, 4.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Net.MAUILibrary.iOS.AMSMB2Interop@4.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Net.MAUILibrary.iOS.AMSMB2Interop&version=4.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Net.MAUILibrary.iOS.AMSMB2Interop&version=4.0.3
                    
Install as a Cake Tool

AMSMB2

This is small Swift library for iOS, macOS and tvOS which wraps libsmb2 and allows to connect a SMB2/3 share and do file operation.

Swift Version Compatibility Platform Compatibility License Release version

Getting Started

To use AMSMB2, add the following dependency to your Package.swift:

dependencies: [
    .package(url: "https://github.com/amosavian/AMSMB2", .upToNextMinor(from: "3.0.0"))
]

You can then add the specific product dependency to your target:

dependencies: [
    .product(name: "AMSMB2", package: "AMSMB2"),
]

Usage

Just read inline help to find what each function does. It's straightforward. It's thread safe.

To do listing files in directory and file operations you must use this template:

import AMSMB2

class SMBClient: @unchecked Sendable {
    /// connect to: `smb://guest@XXX.XXX.XX.XX/share`
    
    let serverURL = URL(string: "smb://XXX.XXX.XX.XX")!
    let credential = URLCredential(user: "guest", password: "", persistence: URLCredential.Persistence.forSession)
    let share = "share"
    
    lazy private var client = SMB2Manager(url: self.serverURL, credential: self.credential)!
    
    private func connect() async throws -> SMB2Manager {
        // AMSMB2 can handle queueing connection requests
        try await client.connectShare(name: self.share)
        return self.client
    }
    
    func listDirectory(path: String) {
        Task {
            do {
                let client = try await connect()
                let files = try await client.contentsOfDirectory(atPath: path)
                for entry in files {
                    print(
                        "name:", entry[.nameKey] as! String,
                        ", path:", entry[.pathKey] as! String,
                        ", type:", entry[.fileResourceTypeKey] as! URLFileResourceType,
                        ", size:", entry[.fileSizeKey] as! Int64,
                        ", modified:", entry[.contentModificationDateKey] as! Date,
                        ", created:", entry[.creationDateKey] as! Date)
                }
            } catch {
                print(error)
            }
        }
    }
    
    func moveItem(path: String, to toPath: String) {
        Task {
            do {
                let client = try await self.connect()
                try await client.moveItem(atPath: path, toPath: toPath)
                print("\(path) moved successfully.")
                
                // Disconnecting is optional, it will be called eventually
                // when `AMSMB2` object is freed.
                // You may call it explicitly to detect errors.
                try await client.disconnectShare()
            } catch {
                print(error)
            }
        }
    }
}

License

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

You must link this library dynamically to your app if you intend to distribute your app on App Store.

Product Compatible and additional computed target framework versions.
.NET net10.0-ios26.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0-ios26.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.3 194 11/26/2025

This package supports only on device.