Skip to content

Conversation

noahsmartin
Copy link
Contributor

@noahsmartin noahsmartin commented Sep 11, 2025

Adds the ETDistribution model to the package.swift

Intentionally not supporting cocoapods or usage from ObjC for now, that can come in a future version.

There are a few ways we could expose this API:

  1. Using the SentrySDK naming so you would do something like SentrySDK.checkForUpdates()
  • a: As an extension from the existing SentrySDK. This is not preferred because it means users would have to depend on both the Sentry target, and the distribution target.
  • b: As a new target containing a new object with the same name. So there would be Sentry.SentrySDK and SentryDistribution.SentrySDK but most of the time you wouldn't need the module prefixes if they are being used in different files.
  1. With a new type name like Distribution. This is what this PR does. The API is:
import SentryDistribution

Updater.checkForUpdates()

Closes #6173


Note

Adds new SentryDistribution SwiftPM target with update-checking API, includes sample app and CI build/test coverage.

  • SDK / SPM:
    • Add SentryDistribution target and SentryDistributionTests in Package.swift.
    • Implement update-checking API (Updater, models, networking, Mach-O UUID parsing, utils) under Sources/SentryDistribution.
  • Samples:
    • Add Samples/DistributionSample app (XcodeGen spec, SwiftUI app, update flow) and include it in workspace and Makefile.
  • CI:
    • Extend .github/actions/prepare-package.swift with remove-duplicate and change-path inputs and conditional steps.
    • Add build-distribution job to build SentryDistribution framework.
    • Add distribution-tests job to run SPM package tests (with duplicate target removal), and wire into required checks.
    • Build matrix: include DistributionSample scheme.
  • Changelog:
    • Unreleased: feature entry for SentryDistribution as a SwiftPM target.

Written by Cursor Bugbot for commit 6e87db3. This will update automatically on new commits. Configure here.

Copy link
Contributor

github-actions bot commented Sep 11, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 6e87db3

Copy link

codecov bot commented Sep 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.812%. Comparing base (0309548) to head (6e87db3).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #6149       +/-   ##
=============================================
+ Coverage   86.807%   86.812%   +0.005%     
=============================================
  Files          438       438               
  Lines        37323     37323               
  Branches     17434     17436        +2     
=============================================
+ Hits         32399     32401        +2     
+ Misses        4879      4876        -3     
- Partials        45        46        +1     

see 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0309548...6e87db3. Read the comment docs.

Copy link
Contributor

github-actions bot commented Sep 11, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1212.69 ms 1238.96 ms 26.26 ms
Size 23.75 KiB 994.73 KiB 970.99 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
e3ebff3 1223.47 ms 1249.27 ms 25.80 ms
5218a05 1236.35 ms 1245.41 ms 9.06 ms
7bb24a2 1229.16 ms 1256.66 ms 27.50 ms
8bb3e37 1235.18 ms 1252.63 ms 17.45 ms
9ec4c56 1222.69 ms 1248.77 ms 26.08 ms
fdea6f5 1216.08 ms 1241.82 ms 25.73 ms
0b5fd21 1237.52 ms 1251.36 ms 13.84 ms
55f739c 1226.06 ms 1248.78 ms 22.71 ms
073562b 1232.63 ms 1259.88 ms 27.24 ms
4a7a005 1229.15 ms 1243.35 ms 14.20 ms

App size

Revision Plain With Sentry Diff
e3ebff3 23.75 KiB 878.48 KiB 854.73 KiB
5218a05 23.75 KiB 984.71 KiB 960.96 KiB
7bb24a2 23.75 KiB 973.68 KiB 949.93 KiB
8bb3e37 23.75 KiB 968.25 KiB 944.50 KiB
9ec4c56 23.75 KiB 921.20 KiB 897.45 KiB
fdea6f5 23.75 KiB 867.15 KiB 843.40 KiB
0b5fd21 23.75 KiB 912.78 KiB 889.03 KiB
55f739c 23.75 KiB 858.73 KiB 834.98 KiB
073562b 23.75 KiB 927.06 KiB 903.31 KiB
4a7a005 23.75 KiB 979.96 KiB 956.22 KiB

Previous results on branch: addDistribution

Startup times

Revision Plain With Sentry Diff
9478181 1222.62 ms 1247.98 ms 25.35 ms
e4e9fa7 1234.24 ms 1261.62 ms 27.38 ms
b03d8aa 1233.00 ms 1255.20 ms 22.20 ms
b606360 1235.00 ms 1255.91 ms 20.91 ms
7a3001a 1229.40 ms 1262.56 ms 33.16 ms
a40faec 1206.49 ms 1231.98 ms 25.49 ms
4efe26d 1208.45 ms 1238.27 ms 29.82 ms
2c7d1f4 1225.24 ms 1249.27 ms 24.02 ms
5b58113 1221.59 ms 1248.87 ms 27.27 ms
cde82dd 1218.43 ms 1241.29 ms 22.86 ms

App size

Revision Plain With Sentry Diff
9478181 23.75 KiB 974.94 KiB 951.20 KiB
e4e9fa7 23.75 KiB 974.94 KiB 951.20 KiB
b03d8aa 23.75 KiB 974.89 KiB 951.14 KiB
b606360 23.75 KiB 980.80 KiB 957.05 KiB
7a3001a 23.75 KiB 979.09 KiB 955.35 KiB
a40faec 23.75 KiB 974.89 KiB 951.14 KiB
4efe26d 23.75 KiB 977.31 KiB 953.57 KiB
2c7d1f4 23.75 KiB 979.96 KiB 956.21 KiB
5b58113 23.75 KiB 974.89 KiB 951.14 KiB
cde82dd 23.75 KiB 979.96 KiB 956.21 KiB

@noahsmartin noahsmartin force-pushed the addDistribution branch 6 times, most recently from b403705 to ea23f05 Compare September 15, 2025 21:09
@noahsmartin noahsmartin marked this pull request as ready for review September 15, 2025 21:09
cursor[bot]

This comment was marked as outdated.

Copy link
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

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

Left some comments. As we start a new SDK here, we can make sure to build a best-practice solution from the beginning.

@philprime
Copy link
Member

Why do you want to skip the changelog when introducing such a big new feature?

@noahsmartin
Copy link
Contributor Author

I don't think we would actually skip the changelog, I just want to align on the API before writing a changelog, and don't want the bot to post that big comment on the PR

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@noahsmartin noahsmartin force-pushed the addDistribution branch 5 times, most recently from 609afa7 to 919ce11 Compare September 18, 2025 21:33
@noahsmartin
Copy link
Contributor Author

Thanks @philprime for the review, just updated it. PTAL whenever you get a chance

Copy link
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

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

Good progress. I left some further comments to consider.

Regarding this comment:

I don't think we would actually skip the changelog, I just want to align on the API before writing a changelog, and don't want the bot to post that big comment on the PR

In that case it would still be better to have a draft changelog message, because right now it would just skip the CI job due to the skip-changelog, also not blocking any auto-merge attempt.

@noahsmartin noahsmartin force-pushed the addDistribution branch 4 times, most recently from c13bea0 to fcf0050 Compare September 22, 2025 20:27
cursor[bot]

This comment was marked as outdated.

@noahsmartin noahsmartin force-pushed the addDistribution branch 4 times, most recently from 273faf4 to d3e6583 Compare September 23, 2025 01:17
@noahsmartin
Copy link
Contributor Author

Thanks @philprime it's ready for another pass whenever you get a chance!

cursor[bot]

This comment was marked as outdated.

Copy link
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

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

Cursor left another comment you might want to consider, other than that LGTM. Thanks for applying all my feedback.

Copy link

cursor bot commented Sep 26, 2025

I enhanced the BinaryParser's robustness by making the _dyld_get_image_uuid symbol lookup optional and handling cases where the symbol might not be found. This prevents potential crashes and allows getMainBinaryUUID to gracefully return nil, improving error handling.

  • I modified the _dyld_get_image_uuid constant in Sources/SentryDistribution/Mach-O/BinaryParser.swift to be an optional GetUUIDFuncType?. I wrapped the dlsym call in a guard let to safely handle scenarios where the symbol might not be present, returning nil if it's not found.
  • I updated the getMainBinaryUUID function signature in BinaryParser.swift to accept an optional GetUUIDFuncType? for its getUUID parameter. I also added a guard let inside the function to ensure getUUID is unwrapped, returning nil if the symbol is unavailable.
  • In Sources/SentryDistributionTests/BinaryParserTests.swift, I updated testBinaryParserGetsCorrectUUID to explicitly pass the mock getUUID closure. I also added a new test, testBinaryParserHandlesNilUUID, to verify that getMainBinaryUUID correctly returns nil when the getUUID function is not provided.

3 tasks completed

  • Examine the SentryDistribution codebase structure and locate the BinaryParser.swift file
  • Fix the null pointer dereference bug in BinaryParser.swift for _dyld_get_image_uuid
  • Review and address any remaining feedback in Updater.swift
    Open in Cursor Open in Web

Learn more about Cursor Agents

cursor[bot]

This comment was marked as outdated.

@philprime
Copy link
Member

@noahsmartin I did not expect the bot to change the PR, you might want to revert the last commit

cursor[bot]

This comment was marked as outdated.

@noahsmartin noahsmartin merged commit 5b469c0 into main Sep 29, 2025
211 of 220 checks passed
@noahsmartin noahsmartin deleted the addDistribution branch September 29, 2025 19:55
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.

feat: Add SentryDistribution
2 participants