Effortlessly read and write Microsoft Project files in Swift.
Project details
MPPKit provides a native Swift solution for reading and writing Microsoft Project .mpp files on macOS and iPadOS. This tool operates without a JVM or .NET, allowing seamless integration and compatibility. Building on the foundation of MPP Studio, MPPKit ensures quality outputs by matching Microsoft Project standards, making it ideal for Apple developers.
MPPKit is a native Swift library designed for reading and writing Microsoft Project .mpp files on macOS and iPadOS. This library allows developers to work with .mpp files without relying on external dependencies such as JVM or .NET, or requiring Microsoft Project to be installed on the machine.
As the file-format layer of MPP Studio, MPPKit provides robust features for opening, editing, and saving project files while maintaining data integrity and precision. The library is published under the GNU AGPL v3 license.
The .mpp format is one of the last key legacy Office formats without a published Microsoft specification and lacks open-source libraries in Swift and Objective-C. MPPKit addresses this gap by supporting MPP14 format, which is prevalent among existing files. The library automatically adapts to variations in field order and record layout, making it resilient to changes in project files.
MPPKit’s design is flexible and does not hard-code any specifications from Microsoft Project versions. It dynamically reads record offsets, item sizes, and flags directly from the file’s own data structures, ensuring precise data manipulation.
Writing a project file involves a unique approach where MPPKit utilizes a previously saved project file as a baseline template, retaining all necessary metadata while updating critical project data. This method ensures that the integrity and original properties of the file are preserved during editing.
Reading an .mpp file:
import MPPKit
let project = try MPP14File(path: "plan.mpp").readProject()
for task in project.tasks {
print(task.rowID, task.name, task.durationDays, task.start.map(MPPTime.iso) ?? "-")
}
Editing and writing to a new .mpp file:
var p = project
p.tasks[1].name = "Renamed"
try Scheduler.schedule(&p) // recompute dates after edits
let writer = try MPP14Writer(templateURL: URL(fileURLWithPath: "Samples/Blank-Template.mpp"))
try writer.write(p, to: URL(fileURLWithPath: "plan-edited.mpp"))
Although MPPKit covers a broad range of project aspects, certain features such as material resources, hyperlinks, and recurring tasks are yet to be modeled completely within the framework.
Contribution of bug reports is encouraged, especially regarding .mpp files that may not be processed correctly. For guidelines on contributing and reporting, refer to CONTRIBUTING.md.
MPPKit enhances the workflow for developers working with Microsoft Project files and makes it easier to manage project data in a Swift-native environment.
Comments
0Start the conversation
Share the first comment.