Add Support for the Swift Package Manager
Is your feature request related to a problem? Please describe.
Hi everyone! Thanks for maintaining and improving CardinalKit! 🚀 I have the following feature suggestion: CardinalKit currently supports CocoaPods to manage dependencies. The Swift Package Manager is an alternative tool for managing Swift dependencies bundled with the Swift compiler and directly supported in Xcode. Adding a dependency using the Swift Package Manager is supported by an easy UI workflow in the Xcode IDE.
Describe the solution you'd like
It would be great if CardinalKit could also support the Swift Package Manager as an option to add the library as a dependency to other projects. After investigating the current project structure adding a Swift Package manifest seems to be no problem. The dependencies currently used might cause more challenges:
- ⚠️
SAMKeychainversion 1.x: Is no longer maintained, does not support the Swift Package Manager, and is archived by its owner. Would need a replacement. - ✅
RealmSwiftversion 10.x: Maintained and supports the Swift Package Manager - ✅
ObjectMapperversion 3.x: Maintained and supports the Swift Package Manager from version 4.x on. - ✅
SwiftyJSONversion 10x: Maintained and supports the Swift Package Manager - ✅
ReachabilitySwiftversion 3.X: Maintained and supports the Swift Package Manager in version 5.x. - ✅
Zipversion 1.x: Maintained and supports the Swift Package Manager in version 2.x - ⚠️
Granolawith no specified version constraints: No longer maintained and does not support the Swift Package Manager. Libraries like HealthKitReporter could be an alternative.
Describe alternatives you've considered
An alternative to finding new dependencies that would replace the deprecated/outdated dependencies would be rewriting the functionality in CardinalKit itself:
- I have written a few Keychain API wrappers myself, so doing so for
SAMKeychainshould be doable. - Rewriting the functionality of Granola might be a bit more complicated. I would need to further investigate the functionality CardinalKit currently uses there. It would be possible to make the HealthKit types conform to the Swift
Codableprotocol.
Both JSON-related dependencies (SwiftyJSON and ObjectMapper) could also be replaced with the usage of the Swift Codable protocol.
Next Steps
Feel free to let me know what you think about the feature suggestion and if this would be something you would be interested in. I would be happy to help along the way. We would probably need to discuss the different dependency-related issues and unmaintained dependencies before we add support for the Swift Package Manager.
I think we may be able to replace SAMKeychain with keychain-swift (#130). Granola will require a port to Swift. ResearchKit also doesn't support SPM at the moment, unclear if/when they plan to.
This issue is being addressed in the new version of CardinalKit, which is based on Swift Package Manager: https://github.com/stanfordbdhg/cardinalkit