Simple package which wraps an SQLite database containing Pathfinder 1e spells.
This package assumes the developer has some knowledge of the Pathfinder RPG.
In XCode, File > Swift Packages > Add Package Dependency.
Main classes and structs.
actor SpellDBAccessClass that that accesses the SQLite database. Uses C api.
class SpellClass that contains the metadata for a spell. Has an extension which provides a lot of convenince accessors.
actor SpellStorageSimple storage class for the Spell class.
struct SpellFieldsStruct with properties that match the SQLite database spell columns.
extension StringStuff
Utility methods for String.
Download macOS demo app here demonstrating basic usage of the SPM.
From the demo app:
struct SpellData : Identifiable {
let id = UUID()
let name : String
var school : SpellSPM.SpellSchools? = nil
}
@MainActor
@Observable
class SpellListModel {
let spellStore : SpellSPM.SpellStorage
let db : SpellSPM.SpellDBAccess
init() {
spellStore = try! SpellStorage()
db = try! SpellSPM.SpellDBAccess()
}
var spells : [SpellData] = []
func reloadSpells() {
Task {
guard let s = try? await db.getAllNames(force: true) else { return }
self.spells = s.map({ S in
return SpellData(name: S)
})
}
}
}