DittoSwiftTools are diagnostic tools for Ditto. You can view connected peers, export debug logs, browse collections/documents and see Ditto's disk usage.
Issues and pull requests welcome!
The recommended approach to use DittoSwiftTools in your project is using the Swift Package Manager.
If you are looking for compatibility with Ditto v4, please target the v4 branch in the Swift Package Manager.
There are four targets in this package: Presence Viewer, Data Browser, Export Logs, Disk Usage.
The Presence Viewer displays a mesh graph that allows you to see all connected peers within the mesh and the transport that each peer is using to make a connection.
First, make sure the "DittoPresenceViewer" was added to your Target.
Then, use import DittoPresenceViewer
to import the Presence Viewer
You can use the Presence Viewer in SiwftUI or UIKit
SwiftUI
Use PresenceView(ditto: Ditto)
and pass in your Ditto instance to display the mesh graph.
import DittoPresenceViewer
struct PresenceViewer: View{
var body: some View {
PresenceView(ditto: DittoManager.shared.ditto)
}
}
UIKit
Call present and pass DittoPresenceView(ditto: DittoManager.shared.ditto).viewController
as a parameter. Set animated
to true
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
present(DittoPresenceView(ditto: DittoManager.shared.ditto).viewController, animated: true) {
if let selected = tableView.indexPathForSelectedRow {
tableView.deselectRow(at: selected, animated: true)
}
}
}
The Ditto Data Browser allows you to view all your collections, documents within each collection and the propeties/values of a document. With the Data Browser, you can observe any changes that are made to your collections and documents in real time.
Standalone App
If you are using the Data Browser as a standalone app, there is a button, Start Subscriptions
, you must press in order to start syncing data.
If you are embedding the Data Browser into another application then you do not need to press Start Subscriptions
as you should already have your subscriptions running.
First, make sure the "DittoDataBrowser" was added to your Target.
Then, use import DittoDataBrowser
to import the Data Browser.
SwiftUI
Use DataBrowser(ditto: Ditto)
and pass in your Ditto instance to display the Data Browser.
import DittoDataBrowser
struct DataBrowserView: View {
var body: some View {
DataBrowser(ditto: DittoManager.shared.ditto)
}
}
UIKit
Pass DataBrowser(ditto: Ditto)
to a UIHostingController which will return a view controller that you can use to present.
let vc = UIHostingController(rootView: DataBrowser(ditto: DittoManager.shared.ditto))
present(vc, animated: true)
Export Logs allows you to export a file of the logs from your applcation.
First, make sure the "DittoExportLogs" was added to your Target.
Then, use import DittoExportLogs
to import the Export Logs.
SwiftUI
Use ExportLogs()
to export the logs. It is reccomended to call ExportLogs
from within a sheet.
.sheet(isPresented: $isPresented) {
ExportLogs()
}
UIKit
Pass ExportLogs()
to a UIHostingController which will return a view controller that you can use to present.
let vc = UIHostingController(rootView: ExportLogs())
present(vc, animated: true)
Disk Usage allows you to see Ditto's file space usage.
First, make sure the "DittoDiskUsage" was added to your Target.
Then, use import DittoDiskUsage
to import the Disk Usage.
SwiftUI
Use DittoDiskUsageView(ditto: Ditto)
and pass in your Ditto instance.
import DittoDiskUsage
struct DiskUsageViewer: View {
var body: some View {
DittoDiskUsageView(ditto: DittoManager.shared.ditto)
}
}
UIKit
Pass DittoDiskUsageView(ditto: Ditto)
to a UIHostingController which will return a view controller that you can use to present.
let vc = UIHostingController(rootView: DittoDiskUsageView(ditto: DittoManager.shared.ditto))
present(vc, animated: true)
ExportData allows you to export the Ditto store directory as a zip file.
SwiftUI
Use ExportData(ditto: ditto)
to get UIActivityViewController
and call it within a sheet.
.sheet(isPresented: $isPresented) {
ExportData(ditto: ditto)
}
UIKit
Pass UIActivityViewController
(return value of ExportData(ditto: ditto)
) to UIHostingController which will return a view controller that you can use to present.
let vc = UIHostingController(rootView: ExportData(ditto: ditto))
present(vc, animated: true)
Swift tools
xcodebuild: error: Could not resolve package dependencies:
package at 'http://github.com/getditto/DittoSwiftTools' @ 0ae82dcc1031d25ce5f6f20735b666312ecb2e53 is using Swift tools version 5.6.0 but the installed version is 5.5.0 in http://github.com/getditto/DittoSwiftTools
Solution: Update to the latest version of XCode to get new Swift versions.
Send us an email at [email protected] or submit a form.
Copyright © 2023 DittoLive
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
link |
Stars: 7 |
Last commit: 10 hours ago |
This release is compatible with DittoSwift version 4.0.0 and above.
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics