A PocketBase client for iOS, macOS, watchOS, and tvOS

Overview

PocketBase

A pure Swift client for interfacing with a PocketBase instance.

Getting Started

Development Environment

Easiest way to get started with PocketBase for Swift is to run an instance inside of a Docker container.

Run the following commands to start PocketBase locally:

cd <path>/PocketBase/Developer
docker-compose up

You should then see something like:

Starting pocketbase ... done
Attaching to pocketbase
pocketbase    | > Server started at: http://0.0.0.0:8090
pocketbase    |   - REST API: http://0.0.0.0:8090/api/
pocketbase    |   - Admin UI: http://0.0.0.0:8090/_/

Now you're ready to incorporate the library.

The Codes

The PocketBase Swift library defaults to sending requests to the default PocketBase docker image URL: http://0.0.0.0:8090/`.

import PocketBase // <~ 1.
import SwiftUI
  1. Import PocketBase to your project.
@main
struct TestApp: App {
    
    @Client var client: PocketBase // <~ 2
    
    var body: some Scene {
        WindowGroup {
            ContentView()
                .environmentObject(client) // <~ 3
                .environment(\.baseUrl,  URL(string: "http://0.0.0.0:8090/")!) // <~ 4 (Optional)
        }
    }
}
  1. Create an instance of PocketBase with the @Client property wrapper. This internally creates a singleton that lives throughout the lifecycle of your app.
  2. Add the client to the environment so that child views can access the singleton.
  3. Optionally specify the URL where your PocketBase instance is served. If this is omitted the URL will default to http://0.0.0.0:8090/.
struct Test: Codable, Identifiable { // <~ 5
    var id: String?
    var foo: String
}
  1. Create the model object. Must conform to both Codable and Identifiable.
struct ContentView: View {
    
    @Query("test") var tests: [Test] // <~ 6
    
    var body: some View {
        NavigationView {
            List {
                ForEach(tests) { test in // <~ 7
                    Text(test.foo)
                }
            }
            .navigationTitle("Tests Collection")
        }
    }
}
  1. Create a @Query instance. This is the object that does the most magic. It will download the records for the given collection and then subscribe to realtime updatest to keep the server and the client in sync.
  2. Display the data in your view.
You might also like...
Unofficial Notion API SDK for iOS & macOS
Unofficial Notion API SDK for iOS & macOS

NotionSwift Unofficial Notion SDK for iOS & macOS. This is still work in progress version, the module interface might change. API Documentation This l

Fetch the update available status for iOS or macOS apps based on the bundle identifier.

AppUpdately Fetch the update status for a given app bundle identifier, without the need of any remote configuration. Simply provide your app's bundle

The Gini Bank SDK provides components for capturing, reviewing and analyzing photos of invoices and remittance slips.
The Gini Bank SDK provides components for capturing, reviewing and analyzing photos of invoices and remittance slips.

Gini Bank SDK for iOS The Gini Bank SDK provides components for capturing, reviewing and analyzing photos of invoices and remittance slips. By integra

Zilla connect is an easy, fast and secure way for your users to buy now and pay later from your app

Zilla Checkout iOS SDK Zilla connect is an easy, fast and secure way for your us

Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.
Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Accept credit cards and PayPal in your iOS app
Accept credit cards and PayPal in your iOS app

Important: PayPal Mobile SDKs are Deprecated. The APIs powering them will remain operational long enough for merchants to migrate, but the SDKs themse

Unopinionated and flexible library for easily integrating Tumblr data into your iOS or OS X application.

Tumblr SDK for iOS An unopinionated and flexible library for easily integrating Tumblr data into your iOS or OS X application. The library uses ARC re

Build, Measure and Grow iOS subscription business

Apphud SDK Apphud SDK is a lightweight open-source Swift library to manage auto-renewable subscriptions and other in-app purchases in your iOS app. No

Sample app to demonstrate the integration code and working of Dyte SDK for iOS, using Objective-C.
Sample app to demonstrate the integration code and working of Dyte SDK for iOS, using Objective-C.

iOS sample app (using Objective-C) by dyte Sample app to demonstrate the usage of Dyte iOS SDK Explore the docs » View Demo · Report Bug · Request Fea

Owner
Brianna Zamora
Developer, Musician, Engineer, Designer, Producer, Co-Worker, Tech Support, Guitarist, Singer, Entrepreneur, Cook, Yogi, Furmom, Friend.
Brianna Zamora
A simple to use iOS/tvOS/watchOS SDK to help get you off the ground quickly and efficiently with your Elastic Path Commerce Cloud written in Swift.

Elastic Path Commerce Cloud iOS Swift SDK A simple to use iOS/tvOS/watchOS SDK to help get you off the ground quickly and efficiently with your Elasti

Moltin 36 Aug 1, 2022
Open-source API Client for iOS, iPadOS, macOS. Built with SwiftUI

Yogu Open-source API Client for iOS, iPadOS, macOS. Built with SwiftUI ?? Yogu is currently in development, and not actually usable yet. Please DO NOT

Beomjun Gil 5 Oct 29, 2022
Symptoms - WatchOS app to save symptoms to HealthKit

Symptoms Symptoms is a watchOS app for entering symptoms into HealthKit Screensh

Leptos 1 Sep 4, 2022
Used to integrate the Facebook Platform with your iOS & tvOS apps.

Facebook SDK for iOS This open-source library allows you to integrate Facebook into your iOS app. Learn more about the provided samples, documentation

Meta 7.3k Jan 3, 2023
Project Flat iOS is the iOS client of Agora Flat open source classroom.

Agora Flat iOS Project flat is the iOS client of Agora Flat open source classroom. 中文 Features Open sourced front-end and back-end [Flat Web][flat-web

netless 24 Dec 12, 2022
Native iOS implementation of RadarCOVID tracing client using DP3T iOS SDK

RadarCOVID iOS App Introduction Native iOS implementation of RadarCOVID tracing client using DP3T iOS SDK Prerequisites These are the tools used to bu

Radar COVID 146 Nov 24, 2022
⚡️ A fully-featured and blazing-fast Swift API client to interact with Algolia.

The perfect starting point to integrate Algolia within your Swift project Documentation • Community Forum • Stack Overflow • Report a bug • FAQ • Supp

Algolia 192 Dec 23, 2022
Client library for accessing Azure Storage on an iOS device

Azure Storage Client Library for iOS Overview This library is designed to help you build iOS applications that use Microsoft Azure Storage. At the mom

Microsoft Azure 81 Oct 15, 2022
MulticoinLightClientKit - A Zcash Lightweight Client SDK for iOS

Zcash iOS Framework A Zcash Lightweight Client SDK for iOS This is an alpha buil

Pirate Chain (ARRR) 0 Aug 27, 2022
MbientLab 2 Feb 5, 2022