EZNetworking

5.6.0

A lightweight Swift networking library for handling API requests.
Aldo10012/EZNetworking

What's New

5.6.0

2026-05-18T01:57:57Z

What's new?

Updated DataUploader to support pause/resume/cancel.

Data Upload

Use DataUploader to upload Data from memory (JSON blobs, encoded models, multipart bodies built in memory, etc.):

let uploader = try DataUploader(data: payload, request: request)

for await event in await uploader.upload() {
    switch event {
    case .progress(let progress):
        // handle progress
    case .completed(let responseData):
        // handle success
    case .failed(let error):
        // handle error
    }
}

Pause, resume, and cancel

let uploader = DataUploader(fileURL: fileURL, request: request)

let eventsTask = Task {
    for await event in await uploader.upload() {
        // handle events
    }
}

try await uploader.pause()
try await uploader.resume()
try await uploader.cancel()

Multipart-form upload

Build the multipart body with MultipartFormData, then upload it through DataUploader:

let boundary = "SOME_BOUNDARY"

let parts: [MultipartFormPart] = [
    MultipartFormPart.fieldPart(
        name: "username",
        value: "Daniel"
    ),
    MultipartFormPart.filePart(
        name: "profile_picture",
        data: fileData,
        filename: "profile.jpg",
        mimeType: .jpeg
    ),
    MultipartFormPart.dataPart(
        name: "metadata",
        data: Data(encodable: user)!,
        mimeType: .json
    )
]
let multipartFormData = MultipartFormData(parts: parts, boundary: boundary)

guard let body = Data(multipartFormData: multipartFormData) else { return }

let request = UploadRequest(
    url: "https://www.example.com/upload",
    additionalheaders: [
        .contentType(.multipartFormData(boundary: boundary))
    ]
)

let uploader = try DataUploader(data: body, request: request)

for await event in await uploader.upload() {
    switch event {
    case .progress(let progress):
        // handle progress
    case .completed(let responseData):
        // handle success
    case .failed(let error):
        // handle error
    }
}

Use the same boundary string in both MultipartFormData and the Content-Type header. Do not assign the multipart body to UploadRequest or any other request body propertyβ€”the upload actors pass the payload via URLSession's file-based upload API instead.

EZNetworking

Swift Platform SPM Compatible

EZNetworking is a powerful, lightweight Swift networking library that simplifies API interactions in your Apple platform applications. Built with modern Swift features, it provides an intuitive interface for making HTTP requests, handling responses, and managing network operations.

Key Features πŸš€

  • Modern Swift Support: Built with Swift 5.9 and iOS 17.0+, macOS 14.0+, watchOS 10.0+, tvOS 17.0+, visionOS 1.0+
  • Async/Await Integration: First-class support for Swift concurrency
  • AsyncStream Support: Streaming progress for uploads, downloads, and real-time events
  • Type-Safe Networking: Strong typing for requests and responses
  • Flexible Request Building: Multiple approaches to creating requests
  • Comprehensive Interceptors: Full request/response pipeline control
  • Cache Control: Configurable URLRequest cache policies and optional cache interceptors
  • File Download: Easy-to-use file downloader
  • File Upload: Easy-to-use file uploader
  • Data Upload: Easy-to-use data uploader
  • Multipart Form Data: Construct multipart requests with boundary handling and MIME types
  • WebSocket: Real-time, bi-directional client-to-server communication
  • Server-Sent Events: Lightweight, server-to-client streaming with automatic reconnection
  • Extensive Testing: Comprehensive unit test suite

Table of Contents πŸ“‘

Installation πŸ“¦

Swift Package Manager

Add EZNetworking to your project using Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/Aldo10012/EZNetworking.git", from: "5.6.0")
]

Or through Xcode:

  1. Go to File > Add Packages
  2. Enter: https://github.com/Aldo10012/EZNetworking.git
  3. Select version: 5.5.3 or later

Quick Start Guide πŸš€

Here's a simple example to get you started:

// Create a request
let request = RequestFactoryImpl().build(
    httpMethod: .GET,
    baseUrlString: "https://api.example.com/data",
    parameters: [.init(key: "userId", value: "123")]
)

// Using async/await
do {
    let response = try await RequestPerformer().perform(
        request: request,
        decodeTo: UserData.self
    )
    print("User data: \(response)")
} catch {
    print("Error: \(error)")
}

Scripts

swiftformat Sources Tests

  • Automatically formats the Swift code according to the rules defined in .swiftformat configuration file.

swiftlint Sources Tests

  • Analyzes the Swift code and reports violations of the rules defined in .swiftlint.yml configuration file.

swiftlint --fix Sources Tests

  • Automatically fixes auto-correctable SwiftLint violations in the code.

Contributing 🀝

Contributions are always welcome! For more details see CONTRIBUTING.md.

License πŸ“„

EZNetworking is available under the MIT license. See the LICENSE file for more info.

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun Jun 21 2026 14:26:45 GMT-0900 (Hawaii-Aleutian Daylight Time)