-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
use gyb to define well-known sample types #30
Conversation
@PSchmiedmayer what's your take on this? On one hand, this kinda introduces a new dependency into the codebase (GYB, though it's really only needed on the package-developer-side, when having changed the list of well-known sample types and wanting to regenerate the file), but on the other hand, it does allow for us to easily support some things we currently would need to implement by hand, and which would potentially be cumbersome to maintain (i.e., easy to accidentally mess up). I thought about whether this could be done using Swift Macros, but AFAIK the answer would be no, since (if we had e.g. an |
…into lukas/gyb-sample-types
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #30 +/- ##
=======================================
Coverage 83.61% 83.61%
=======================================
Files 42 42
Lines 2372 2372
=======================================
Hits 1983 1983
Misses 389 389 Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you for setting this up; looks great!
I am find with using it here, purely developer focused and someone who wants to check out the repo doesn't even have to use it as the generated file is part of the repo; good middle ground.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
use gyb to define well-known sample types
♻️ Current situation & Problem
SpeziHealthKit currently has a hardcoded set of extensions on the
SampleType
struct, which define well-known sample types.This is not easy to maintain, especially if we want to add additional features in the future which should also work on all of these well-known sample types (we do want to do this).
For example, it will at some point become necessary to have the ability to treat
SampleType
s as codable-like objects, in which case we'd need the ability to select a specific well-known sample type, based on its underlying HealthKit identifier.Using the current approach, this is of course possible but it would be rather annoying to implement, and very easy to mess up.
Using GYB instead allows us to have the
SampleType
extensions be created in an automated and well-defined way, and it's a lot easier to add new sample types, or new functionality that needs to be implemented in some way that is aware of all sample types.⚙️ Release Notes
SampleType<HKQuantitySample>(identifier: HKQuantityTypeIdentifier)
SampleType<HKCorrelation>(identifier: HKCorrelationTypeIdentifier)
SampleType<HKCategorySample>(identifier: HKCategoryIdentifier)
(the gyb change is an implementation detail and doesn't affect the public API of the package.
📚 Documentation
unchanged
✅ Testing
unchanged
📝 Code of Conduct & Contributing Guidelines
By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: