How jamf/jamfsync works
Main Components
• JamfSyncApp & UI: The entry point is “JamfSyncApp” (in JamfSync/UI) which initializes the SwiftUI ContentView and related views. This layer encapsulates all user interactions. Within UI, separate views (e.g., AboutView, SettingsView, PackageListView, etc.) allow configuration, display, and progress updates.
• Model Layer: Contains the primary domain objects that drive the business logic. Key classes include DataModel, DistributionPoint, and its subclasses (FileShareDp, Jcds2Dp, FolderDp). The Model also includes types for handling files and checksums (e.g., DpFile, Checksums, and associated utility functions). The “ViewModels” sub-group works as an intermediary between the Model and UI, ensuring that UI state is updated via @Published properties.
• CoreData & Persistence: The CoreData directory stores user settings and other persistent entities (StoredSettings.xcdatamodeld). This layer handles storage for non-sensitive data while secure credentials are stored in the keychain.
• Utility Components: This module consists of helper classes (e.g., ArgumentParser for command line processing, FileHash, FileShare handling, KeychainHelper for secure credential storage, and others that support file operations and network communication).
• External Interactions: Components involved in interacting with external Jamf Pro servers via JamfPro APIs (JamfProPackageApi, JamfProPackageClassicApi, etc.) and additional networking components like CloudSessionDelegate. Also, note the command line interface support for scripted operations.
• Testing: Separate modules (JamfSyncTests and JamfSyncUITests) provide unit testing and UI testing to ensure functionality across modules.
Relationships and Interactions
• The user (or a script via command line) starts the application. The UI layer (rooted in JamfSyncApp) receives user input, which then updates the ViewModels.
• ViewModels observe and communicate changes to the DataModel.
• The DataModel interacts with persistence (CoreData for user settings) and with secure storage (using KeychainHelper) for credentials.
• When a synchronization is triggered (through UI or command line parameters), the DataModel and DistributionPoint objects coordinate:
• They use the copyFiles function to initiate file transfers between the selected source and destination.
• Depending on what type of distribution point is used (FileShareDp, Jcds2Dp, FolderDp), different implementations of file transfer logic are invoked in the Model layer.
• Utility classes (e.g., FileHash for checksums, FileShare for mounting fileshares) are employed to ensure the integrity of file operations.
• APIs (like JamfProPackageApi) are contacted when working with Jamf Pro servers.
• The UI continuously updates (via @Published properties in ViewModels) to reflect the current synchronization status and logs from the LogViewModel.
Architectural Patterns and Design Principles
• Separation of Concerns: The project is partitioned into clear layers (UI, Model, Utility, Persistence) that handle distinct responsibilities.
• MVVM Pattern: With view models residing alongside the Model and communicating directly with the UI (SwiftUI), the MVVM pattern is strongly in use.
• Modularization: Each module (such as Utility or DistributionPoint subtypes) encapsulates specific core functionality and can be extended (for example, to support additional cloud distribution points like AWS or Akamai later).
• Secure Data Handling: Sensitive data is managed via the keychain and Core Data for non-sensitive items.
• Command Line Integration: The application also has a headless mode via ArgumentParser, meaning the design must account for both interactive UI and CLI-driven workflows.