XMind SDK in Swift
This SDK enables you to create and modify xmind(
.xmind) files, and it's written in swift.
- iOS 9+
- macOS 10.11+
Structure of XMind files
XMind file is a zip file which contains several components, including manifest, metadata, sheets and resources.
Resources contains all the resources of this xmind file that like images.
Metadata represents the version of xmind file and the creator.
Sheets contains all of the topics that belong to the each sheets(canvas).
Manifest lists primary files that contained in this xmind file.
If you create a new xmind file, you can directly operate sheets and topics after initializing a
Workbook instance that represents a xmind file.
If you open a existing xmind file. You need call
public func loadManifest() of
Workbook after initializing a workbook to load some base informations. And now you can access the
passwordHint to read and write the password hint. then, you need call
public func loadContent(password: String? = nil) to load the metadata and sheets. When it's loaded, you can operate sheets and topics.
import XMindSDK ... ... let wb = try Workbook.open(filePath: filePath)// This file path which contains an existing xmind file. try wb.loadManifest() try wb.loadContent(password: "123456") let root = wb.allSheets.first!.rootTopic let sub1 = root.addSubTopic("Sub Topic 1") let sub2 = root.addSubTopic("Sub Topic 2") let sub3 = root.addSubTopic("Sub Topic 3") sub3.addSubTopic("Topic 4") sub3.addSubTopic("Topic 5") sub2.addMarker(Marker.Arrow.refresh) root.addMarker(Marker.Flag.darkBlue) sub1.addMarker(Marker.Priority.p2) try wb.save(to: filePath, password: "123456")
Swift Package Manager
.package(url: "https://github.com/xmindltd/xmind-sdk-swift.git", .upToNextMinor(from: "1.0.0"))
This SDK is released under the MIT license. See LICENSE for details.