Skip to content

Releases: fatbobman/PersistentHistoryTrackingKit

Release 1.2.1

13 Dec 09:44

Choose a tag to compare

What's Changed

Documentation Improvements

  • Added CloudKit Usage Recommendations: Important guidance for users working with NSPersistentCloudKitContainer
  • Added Apple's 7-Day Cleanup Strategy: Documentation now includes Apple's recommended cleanup strategy for optimal performance/capacity balance
  • Fixed Issue #7: Addressed concerns about aggressive cleanup causing NSPersistentHistoryTokenExpiredError in CloudKit scenarios

Key Recommendations

When using NSPersistentCloudKitContainer:

  • Use .byDuration(seconds: 60 * 60 * 24 * 7) cleanup strategy (7 days)
  • Do NOT set includingCloudKitMirroring: true in CloudKit scenarios
  • This prevents CloudKit from losing tracking tokens and avoids local database purges

Previous Changes (since 1.2.0)

  • Documentation improvements for CloudKit users

Full Changelog: 1.2.0...1.2.1

1.2.0

13 Dec 09:15
9436f73

Choose a tag to compare

What's New in 1.2.0

Custom Transaction Merger Support

This release introduces support for custom transaction merger implementations, providing flexibility to handle specific use cases such as undo manager conflicts.

Key Features:

  • Public TransactionMergerProtocol: The protocol is now public, allowing developers to create custom merger implementations
  • Dependency Injection: Pass custom merger instances via optional merger parameter in initializers
  • Crash Prevention: Solves critical crashes when NSManagedObjectContext instances have their undoManager property configured
  • Full Backward Compatibility: Existing code continues to work without any changes - defaults to the standard Merger() implementation

Example Usage:

class CustomTransactionMerger: TransactionMergerProtocol {
    func callAsFunction(merge transactions: [NSPersistentHistoryTransaction],
                        into contexts: [NSManagedObjectContext]) {
        for transaction in transactions {
            let notification = transaction.objectIDNotification()
            for context in contexts {
                context.perform {
                    // Temporarily disable undo manager to prevent crashes
                    let undoManager = context.undoManager
                    context.undoManager = nil
                    context.mergeChanges(fromContextDidSave: notification)
                    context.undoManager = undoManager
                }
            }
        }
    }
}

// Use custom merger
let kit = PersistentHistoryTrackingKit(
    // ... other parameters
    merger: CustomTransactionMerger()
)

Credits

Special thanks to @yangyubo for this excellent contribution! This enhancement provides the flexibility needed to handle complex undo manager scenarios while maintaining the simplicity of the default behavior.

Technical Details

  • Follows SOLID principles (Open/Closed Principle)
  • Improves testability through dependency injection
  • All changes are additive with no breaking changes to the public API

Full Changelog: 1.1.0...1.2.0

1.1.0

22 Aug 23:23

Choose a tag to compare

Change the original performAndWait to performAndWaitWithResult to solve the compatibility problem after Xcode 26 beta 5

1.0.9

27 Oct 09:05
adffcf5

Choose a tag to compare

typos fixed by @junping1

1.0.8

07 Jul 08:51
e2a93ce

Choose a tag to compare

Slight performance improvement

1.0.7

19 Jun 09:16
ccd4210

Choose a tag to compare

Add a deduplicator protocol to avoid duplicate records

1.0.6

01 Jan 02:35

Choose a tag to compare

Add buffer and update Readme

1.0.5

12 Aug 08:12

Choose a tag to compare

Fixed a possible accidental deletion when deleting a transaction in a widget.

1.0.4

25 Jul 08:10

Choose a tag to compare

Added includingCloudKitMirroring parameter to add support for toggling Core Data sync state in real time

1.0.2

21 Feb 06:22

Choose a tag to compare

Optimized some codes