Skip to content

Conversation

@BrandonStalnaker
Copy link
Collaborator

Background

  • The MPPersistenceController was implemented as an Objective-C++ file (.mm) which required the C++ standard library ( and ) for SQL statement handling and collection management
  • Objective-C++ files have slower compilation times and add complexity to the build process
  • The C++ features used were limited to basic string operations and vectors that can be easily replaced with Foundation equivalents (NSString, NSMutableArray)
  • This change is necessary for us to switch to source based distribution for SPM

What Has Changed

  • Converted MPPersistenceController.mm to pure Objective-C (MPPersistenceController.m)
    • Replaced std::string with NSString * and const char * for SQL statements
    • Replaced std::vector with NSMutableArray * for collecting query results
    • Replaced C++ string concatenation with NSMutableString and appendFormat:
    • Replaced std::to_string() with [NSString stringWithFormat:]
    • Replaced range-based for loops with Objective-C for-in enumeration
    • Removed using namespace std; and C++ headers
  • Renamed MPPersistenceControllerTests.mm to MPPersistenceControllerTests.m (no C++ features were used in the test file)
  • Updated project.pbxproj to reference the new .m files with correct lastKnownFileType
  • Added additional unit tests for:
    • Breadcrumb save and pruning operations
    • Session archiving and duplicate detection
    • Database open/close operations
    • App and device info retrieval
    • Delete all sessions except specified session
    • Session update operations
    • Max bytes per event/batch calculations

Checklist

  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have tested this locally.

Reference Issue (For employees only. Ignore if you are an outside contributor)

@BrandonStalnaker BrandonStalnaker self-assigned this Jan 28, 2026
@BrandonStalnaker BrandonStalnaker requested a review from a team as a code owner January 28, 2026 21:09
@github-actions
Copy link

github-actions bot commented Jan 28, 2026

📦 SDK Size Impact Report

Measures how much the SDK adds to an app's size (with-SDK minus without-SDK).

Metric Target Branch This PR Change
App Bundle Impact 1.66 MB 1.62 MB -40 KB
Executable Impact 896 bytes 896 bytes +N/A
XCFramework Size 7.94 MB 7.39 MB -564 KB

➡️ SDK size impact change is minimal.

Raw measurements

Target branch (workstation/9.0-Release):

{"baseline_app_size_kb":84,"baseline_executable_size_bytes":75464,"with_sdk_app_size_kb":1784,"with_sdk_executable_size_bytes":76360,"sdk_impact_kb":1700,"sdk_executable_impact_bytes":896,"xcframework_size_kb":8132}

This PR:

{"baseline_app_size_kb":84,"baseline_executable_size_bytes":75464,"with_sdk_app_size_kb":1744,"with_sdk_executable_size_bytes":76360,"sdk_impact_kb":1660,"sdk_executable_impact_bytes":896,"xcframework_size_kb":7568}


NSArray<MPCookie *> *cookies = [NSArray arrayWithObjects:&cookiesVector[0] count:cookiesVector.size()];
return cookies;
return [cookiesArray copy];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to return copy of object?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it correct to return a copy here for immutability? The return type of the function is NSArray not NSMutableArray

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the array is created locally and not stored anywhere, returning a copy doesn’t add meaningful immutability guarantees here and only introduces an extra allocation. Returning an NSMutableArray instance as NSArray is valid, as NSMutableArray is a subclass of NSArray. Mutability is defined by the contract exposed to the caller: the client only sees an NSArray interface.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s not a big deal, but avoiding the extra copy would keep things simpler and slightly more efficient here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants