fix: NSKeyedUnarchiver class mappings for MPUploadSettings backward compat#666
Open
nickolas-dimitrakas wants to merge 2 commits intoworkstation/9.0-Releasefrom
Open
fix: NSKeyedUnarchiver class mappings for MPUploadSettings backward compat#666nickolas-dimitrakas wants to merge 2 commits intoworkstation/9.0-Releasefrom
nickolas-dimitrakas wants to merge 2 commits intoworkstation/9.0-Releasefrom
Conversation
…ckward compat PR #469 used NSKeyedArchiver setClassName:forClass: (the encode direction) which has no effect on decoding. This replaces it with NSKeyedUnarchiver setClass:forClassName: (the decode direction) so persisted upload settings encoded under the old Swift module name (mParticle_Apple_SDK_NoLocation.MPUploadSettings) can be decoded after upgrading to the Obj-C module (mParticle_Apple_SDK.MPUploadSettings). Also extends coverage to MPPersistenceController.m fetchUploads, which reads upload settings blobs from the SQLite uploads table but was not covered by the original fix, causing those rows to be silently skipped and never uploaded. Without this fix, users upgrading from an SDK version where MPUploadSettings was a Swift class will lose queued upload data on first launch post-upgrade. Made-with: Cursor
📦 SDK Size Impact ReportMeasures how much the SDK adds to an app's size (with-SDK minus without-SDK).
➡️ SDK size impact change is minimal. Raw measurementsTarget branch (workstation/9.0-Release): {"baseline_app_size_kb":84,"baseline_executable_size_bytes":75464,"with_sdk_app_size_kb":1772,"with_sdk_executable_size_bytes":76360,"sdk_impact_kb":1688,"sdk_executable_impact_bytes":896,"xcframework_size_kb":5584}This PR: {"baseline_app_size_kb":84,"baseline_executable_size_bytes":75464,"with_sdk_app_size_kb":1772,"with_sdk_executable_size_bytes":76360,"sdk_impact_kb":1688,"sdk_executable_impact_bytes":896,"xcframework_size_kb":5584} |
jamesnrokt
reviewed
Mar 13, 2026
Collaborator
jamesnrokt
left a comment
There was a problem hiding this comment.
One comment but also are there any tests we could / should add?
Contributor
Author
Adding tests as you sent this |
…+initialize Move NSKeyedUnarchiver class name mappings from UploadSettingsUtils into MPUploadSettings +initialize so they are registered automatically by the Obj-C runtime the first time any decode path evaluates [MPUploadSettings class], with no manual wiring required anywhere. Also adds two unit tests: - testFetchUploads_decodesLegacySwiftModuleClassName: verifies fetchUploads correctly decodes SQLite rows whose upload_settings blob was encoded under the legacy Swift module class name. - testRegisterUploadSettingsClassMappings_decodesAllModuleNames: verifies both legacy module names (mParticle_Apple_SDK and mParticle_Apple_SDK_NoLocation) can be decoded into MPUploadSettings after the mapping is registered. Made-with: Cursor
BrandonStalnaker
approved these changes
Mar 13, 2026
denischilik
approved these changes
Mar 13, 2026
thomson-t
approved these changes
Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
PR #543 migrated
MPUploadSettingsfrom Swift to Obj-C, changing the module name frommParticle_Apple_SDK_NoLocationtomParticle_Apple_SDK. PR #469 attempted to fix backward compat for persisted data but used the wrong API (NSKeyedArchiver= encoding direction, no effect on decoding) and missed the SQLite decode path inMPPersistenceController.m.What Has Changed
MPUploadSettings +initializewhich registers legacy class name mappings onNSKeyedUnarchiverautomatically — the Obj-C runtime fires this the first time[MPUploadSettings class]is evaluated, which happens in both decode paths as part ofunarchivedObjectOfClass:[MPUploadSettings class]. No manual wiring needed anywhere.NSKeyedArchivercalls fromUploadSettingsUtils.m.Tests Added
testFetchUploads_decodesLegacySwiftModuleClassName— saves an upload to SQLite with a settings blob encoded under the legacy Swift module class name, then verifiesfetchUploadsdecodes and returns it correctly.testRegisterUploadSettingsClassMappings_decodesAllModuleNames— verifies both legacy module names decode intoMPUploadSettingssuccessfully.Impact Without This Fix
Users upgrading from a pre-migration SDK version lose queued upload data on first launch:
fetchUploadssilently drops rows it can't decode, andprepareBatchesForUpload:nilbatches in-flight messages with no API credentials, causing server rejection.Checklist