Skip to content
rizwankcePublic

About

💾 One Stop place for all your storage

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

78 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift Storage

If you are using the Codable protocol and need an easy way to store and retrieve your objects, you are in the right place. Swift Storage is a simple extension to store/retrieve your Codable objects.

Features

  • Store Codable objects
  • Retrieve stored Codable objects
  • Store Locations
  • Cache
  • Documents
  • User Default
  • NSUbiquitousKeyValueStore
  • Linux compatibility
  • Name Spaced Stores
  • Comprehensive Unit and Integration Test Coverage
  • Complete Documentation

Usage

Considering you have a Codable Job struct like below

struct Job: Codable {
    let company: String
    let position: String
    let description: String
    let url: String
}

To save or retrieve array of Job

import SwiftStorage

// Create a instance of `Storage` with a type and file name
let storage: Storage<[Job]> = Storage(storageType: .document, filename: "remote-jobs.json")

// To Save array of `Job`
storage.save([job1, job2])

// To retrieve stored values of jobs
let jobs = storage.storedValue

// To remove the stored values
storage.clear()

The available storage types are .cache, .document, .userDefaults and .ubiquitousKeyValueStore.

Example

To run the example project, clone the repo, open Example/Storage.xcodeproj in Xcode and run the Storage-Example scheme. The project references the package locally, so there is no install step.

Running tests

Run the test suite from the repository root:

swift test

Requirements

  • Xcode 27+ / Swift 6.2+
  • iOS 26+

Installation

Swift Storage is distributed through the Swift Package Manager only. CocoaPods is not supported.

Xcode

In Xcode, choose File > Add Package Dependencies..., enter the repository URL below, and add the SwiftStorage library to your target:

https://github.com/rizwankce/Storage.git

Package.swift

Add the package as a dependency:

dependencies: [
    .package(url: "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/rizwankce/Storage.git", from: "1.0.0")
]

Then, add SwiftStorage as a dependency of your target:

.target(
    name: "YourTargetName",
    dependencies: [
        .product(name: "SwiftStorage", package: "Storage")
    ]),

Contributing

If you like to contribute to this project, feel free to send PR or raise issues.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Credits

The idea of Swift Storage is originally came from Ben Scheirman from NSScreenCast and most of the code is inspired from one of his series and extended a little with more options.

License

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

About

💾 One Stop place for all your storage

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages