Installation
Prerequisites
Section titled “Prerequisites”- Swift 5.9+
- iOS 15.0+ or macOS 12.0+
- Xcode 14.0+
- PowerSync SDK (already installed)
Swift Package Manager
Section titled “Swift Package Manager”Add ZyraForm to your project using Swift Package Manager:
- In Xcode, go to File → Add Package Dependencies
- Enter the repository URL:
https://github.com/zyraform/swift.git
- Select the version you want to use
- Add ZyraForm to your target
Dependencies
Section titled “Dependencies”ZyraForm requires the following dependencies:
- PowerSync: For offline-first database synchronization
- SwiftUI: For form components (included with iOS/macOS)
Import Statement
Section titled “Import Statement”Once installed, import ZyraForm in your Swift files:
import ZyraFormimport PowerSyncimport SwiftUIConfiguration
Section titled “Configuration”1. Set Up App Config
Section titled “1. Set Up App Config”Define your database prefix (used for table names):
struct AppConfig { static let dbPrefix = "myApp-"}2. Initialize PowerSync Database
Section titled “2. Initialize PowerSync Database”Set up your PowerSync database instance:
import Foundationimport PowerSync
// Define your schema (we'll cover this in Schema Definition)let PowerSyncSchema = Schema( tables: [ // Your tables here ])
// Initialize PowerSynclet db = PowerSyncDatabase( schema: PowerSyncSchema, dbFilename: "myApp-powersync.sqlite")3. Set Up Encryption (Optional)
Section titled “3. Set Up Encryption (Optional)”If you need encryption, configure the encryption manager:
import CryptoKit
// The SecureEncryptionManager is included with ZyraFormlet encryptionManager = SecureEncryptionManager.shared
// Encryption is enabled by default// Disable via UserDefaults if needed:// UserDefaults.standard.set(false, forKey: "useEncryptedStorage")Project Structure
Section titled “Project Structure”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 initializationNext Steps
Section titled “Next Steps”Now that ZyraForm is installed, continue with:
- Quick Start - Build your first form
- Schema Definition - Define your data structure