A Swift package providing Codable and Observable model types for the Dolibarr ERP CRM REST API. Decode JSON responses from the Dolibarr API directly into strongly-typed Swift objects and encode them back for create/update requests.
This is the underlying data model layer for DoliApp by M34D, a native Apple platform client for Dolibarr.
Note: This package is a data model layer only. It does not include networking, authentication, or API client logic. You provide your own HTTP layer (e.g.
URLSession) and use these models to encode/decode the JSON payloads.
- Swift 6.0+
- iOS 18+ / macOS 15+ / Mac Catalyst 18+ / tvOS 18+ / visionOS 2+ / watchOS 11+
- Dolibarr v18+ (may work with older versions of Dolibarr)
Add SwiftDolibarr as a dependency in your Package.swift:
dependencies: [
.package(url: "https://lab.frogg.it/dolibarr/swiftdolibarr.git", from: "1.0.0"),
]Then add it to your target's dependencies:
.target(
name: "YourTarget",
dependencies: ["SwiftDolibarr"]
),| Module | Models |
|---|---|
| Third Parties | DolibarrThirdParty, DolibarrContact |
| Products & Stock | DolibarrProduct, DolibarrWarehouse, DolibarrStockMovement |
| Quotes | DolibarrQuote, DolibarrQuoteLine |
| Orders | DolibarrOrder, DolibarrOrderLine |
| Invoices | DolibarrInvoice, DolibarrInvoiceLine |
| Interventions | DolibarrIntervention, DolibarrInterventionLine |
| Expense Reports | DolibarrExpenseReport, DolibarrExpenseReportLine |
| Projects & Tasks | DolibarrProject, DolibarrTask |
| Agenda Events | DolibarrAgendaEvent |
| Users | DolibarrUser, DolibarrUserPermissions |
import SwiftDolibarr
let data: Data = // ... JSON from Dolibarr REST API
let decoder = JSONDecoder()
// Decode a single invoice
let invoice = try decoder.decode(DolibarrInvoice.self, from: data)
print(invoice.ref) // e.g. "FA2026-0001"
print(invoice.totalInclTax) // e.g. "1200.00"
// Decode a list of third parties
let thirdParties = try decoder.decode([DolibarrThirdParty].self, from: data)let newInvoice = DolibarrInvoice(
date: Int(Date().timeIntervalSince1970),
typeCode: "0",
paidCode: "0",
lines: [],
thirdPartyId: "42",
statusCode: "0"
)
let encoder = JSONEncoder()
let jsonData = try encoder.encode(newInvoice)
// Send jsonData to the Dolibarr APIEach object type has predefined statuses mapped from Dolibarr statuses:
let invoice: DolibarrInvoice = // ...
let status = invoice.statusAll models conform to Codable, Hashable, Identifiable, and are marked @Observable for seamless SwiftUI integration. The type hierarchy is:
DolibarrObject— Base protocol enforcingidpropertyCommonBusinessObject— Base class adding status, entity, notes, and extra fieldsCommonCommercialTransactionObject— Transactional class adding ref, totals, linked third party, and currency for documents (invoices, orders, quotes)DolibarrThirdPartyDolibarrProductDolibarrQuote...- Final object classes
Property names are mapped to Dolibarr API field names via CodingKeys, so you work with idiomatic Swift naming while the JSON stays compatible with the Dolibarr API.
Contributions are welcome! This project is maintained by M34D. Please see CONTRIBUTING.md for guidelines on reporting bugs, suggesting features, submitting changes, and adding new models.
This project uses Semantic Versioning with the following scheme: MAJOR.MINOR.PATCH
Swift Dolibarr is licensed under the Apache License 2.0. See LICENSE for details.