Contents

0xWDG/iCloudStorage

iCloudStorage is a property wrapper around NSUbiquitousKeyValueStore to easily access your shared UserDefaults.

Requirements

  • Swift 5.9+ (Xcode 15+)
  • iOS 13+, macOS 10.15+

Installation (Pakage.swift)

dependencies: [
    .package(url: "https://github.com/0xWDG/iCloudStorage.git", branch: "main"),
],
targets: [
    .target(name: "MyTarget", dependencies: [
        .product(name: "iCloudStorage", package: "iCloudStorage"),
    ]),
]

Installation (Xcode)

  1. In Xcode, open your project and navigate to File β†’ Swift Packages β†’ Add Package Dependency...
  2. Paste the repository URL (https://github.com/0xWDG/iCloudStorage) and click Next.
  3. Click Finish.

Usage

import SwiftUI
import iCloudStorage

struct ContentView: View {
    @iCloudStorage("key")
    var value: String = "default"

    var body: some View {
        VStack {
            Text(value)

            Button("Change value") {
                value = "Hello there at \(Date())"
            }
        }
        .task {
            value = "Hello there"
        }
        .padding()
    }
}

Contact

πŸ¦‹ @0xWDG 🐘 mastodon.social/@0xWDG 🐦 @0xWDG 🧡 @0xWDG 🌐 wesleydegroot.nl πŸ€– Discord

Interested learning more about Swift? Check out my blog.

Package Metadata

Repository: 0xWDG/iCloudStorage

Homepage: https://0xwdg.github.io/iCloudStorage/

Stars: 8

Forks: 0

Open issues: 2

Default branch: main

Primary language: swift

License: MIT

Topics: 0xwdg, hacktoberfest, icloud, key-value-store, nsubiquitouskeyvaluestore, propertywrapper, swift, swiftui

README: README.md