Skip to content

Installation

  • Swift 5.9+
  • iOS 15.0+ or macOS 12.0+
  • Xcode 14.0+
  • PowerSync SDK (already installed)

Add ZyraForm to your project using Swift Package Manager:

  1. In Xcode, go to File → Add Package Dependencies
  2. Enter the repository URL:
    https://github.com/zyraform/swift.git
  3. Select the version you want to use
  4. Add ZyraForm to your target

ZyraForm requires the following dependencies:

  • PowerSync: For offline-first database synchronization
  • SwiftUI: For form components (included with iOS/macOS)

Once installed, import ZyraForm in your Swift files:

import ZyraForm
import PowerSync
import SwiftUI

Define your database prefix (used for table names):

struct AppConfig {
static let dbPrefix = "myApp-"
}

Set up your PowerSync database instance:

import Foundation
import PowerSync
// Define your schema (we'll cover this in Schema Definition)
let PowerSyncSchema = Schema(
tables: [
// Your tables here
]
)
// Initialize PowerSync
let db = PowerSyncDatabase(
schema: PowerSyncSchema,
dbFilename: "myApp-powersync.sqlite"
)

If you need encryption, configure the encryption manager:

import CryptoKit
// The SecureEncryptionManager is included with ZyraForm
let encryptionManager = SecureEncryptionManager.shared
// Encryption is enabled by default
// Disable via UserDefaults if needed:
// UserDefaults.standard.set(false, forKey: "useEncryptedStorage")

We recommend organizing your project like this:

YourProject/
├── Models/
│ ├── Schemas/
│ │ └── UserSchema.swift # ExtendedTable definitions
│ ├── FormValues/
│ │ └── UserFormValues.swift # FormValues structs
│ └── Records/
│ └── User.swift # Swift model structs
├── Services/
│ └── UserService.swift # GenericPowerSyncService instances
├── Views/
│ └── Forms/
│ └── UserFormView.swift # SwiftUI form views
└── App/
└── App.swift # PowerSync initialization

Now that ZyraForm is installed, continue with: