Conversation
69fe1b4 to
f953a24
Compare
🐦 Swift Migration ProgressProduction implementation code at
Objective-C retained by design: Core SDK 5,803 · SDK kit infrastructure 2,041 · Standalone kits 0. This PR's code movement
How this is measured
Generated with |
📦 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/swift-migration): {"baseline_app_size_kb":84,"baseline_executable_size_bytes":75464,"with_sdk_app_size_kb":2624,"with_sdk_executable_size_bytes":76312,"sdk_impact_kb":2540,"sdk_executable_impact_bytes":848,"xcframework_size_kb":6980}This PR: {"baseline_app_size_kb":84,"baseline_executable_size_bytes":75464,"with_sdk_app_size_kb":2644,"with_sdk_executable_size_bytes":76312,"sdk_impact_kb":2560,"sdk_executable_impact_bytes":848,"xcframework_size_kb":7000} |
PR SummaryMedium Risk Overview Swift adds
Behavior fix: a non-dictionary element in Reviewed by Cursor Bugbot for commit f5694a2. Bugbot is set up for automated code reviews on this repo. Configure here. |
508847b to
5e9863a
Compare
8449bf6 to
471b6ed
Compare
471b6ed to
f127c9c
Compare
Second slice of MPConvertJS, after the promotion and transaction-attribute readers. MPConvertJS.m goes from 262 to 210 sloc; 307 before the pair. +productFieldsFromJSON: replaces ten guarded reads, and +identityRequestFromJSON: replaces the UserIdentities walk. Constructing MPProduct and MPIdentityApiRequest stays in the .m, as does every MPILogError. Unlike the promotion reader, product assignments stay guarded in the .m. name, sku and quantity are declared nonnull on MPProduct and position is a scalar, so "absent" and "nil" are not interchangeable here the way they were for MPPromotion, whose setters remove their key on nil. The DTO therefore exposes every field as optional, including position as an NSNumber the .m only reads when non-nil. Behaviours preserved deliberately, each with a test: - Price has two branches. An NSNumber passes through; a string goes through -doubleValue, which yields 0 for text that is not a number, so "abc" still produces 0 rather than being dropped. - Position was read with -unsignedIntValue, not -unsignedIntegerValue. - Product attributes required both the key and the value to be strings. - The identity payload has two distinct failure modes that are not interchangeable: a missing or non-array UserIdentities logged before returning nil, while a single malformed entry returned nil silently and discarded the identities already applied. The Swift result reports which, so the .m keeps the log at its original site. - The top-level Identity/Type pair is applied after the array, so a duplicated type keeps last-write-wins. The pairs are returned in application order. - requestWithEmptyUser is still called before validation, in case it ever does more than allocate. One hardening: an entry that is not a dictionary crashed the ObjC, which typed the enumeration block NSDictionary * and subscripted it unguarded. It now reports a malformed entry. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
xcodebuild analyze flagged price/position/quantity's presence checks as pointer-to-bool conversions. The existing comment already documents the intent as a presence check, not a truthiness check (0 is a valid price, position, or quantity) — implicit bool happened to read the same as != nil for typical values but was the wrong check to write.
f127c9c to
f5694a2
Compare
Background
Second slice of
MPConvertJS: product and identity JSON parsing.What Has Changed
productFieldsFromJSON:andidentityRequestFromJSON:toMPConvertJSFields.swift. 262 → 210 SLOC.ifguards in the.m—MPProducthasnonnullstring/number properties and a scalarposition, so "absent" and "nil" aren't interchangeable here.-doubleValue(non-numeric strings → 0);positionreads via-unsignedIntValue; product attributes require both key and value to be strings; a missing/non-arrayUserIdentitiesvs. a single malformed identity entry log and fail differently (the Swift result reports which); last-write-wins on duplicate identity types.UserIdentitiespreviously crashed (-[NSString objectForKeyedSubscript:]); now reports a malformed entry instead.Validation
abi-guardPASSEDtrunk checkcleanStack
Depends on #929.
Checklist