CardinalKit icon indicating copy to clipboard operation
CardinalKit copied to clipboard

Add Support for the Swift Package Manager

Open PSchmiedmayer opened this issue 3 years ago • 1 comments

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:

  • ⚠️ SAMKeychain version 1.x: Is no longer maintained, does not support the Swift Package Manager, and is archived by its owner. Would need a replacement.
  • RealmSwift version 10.x: Maintained and supports the Swift Package Manager
  • ObjectMapper version 3.x: Maintained and supports the Swift Package Manager from version 4.x on.
  • SwiftyJSON version 10x: Maintained and supports the Swift Package Manager
  • ReachabilitySwift version 3.X: Maintained and supports the Swift Package Manager in version 5.x.
  • Zip version 1.x: Maintained and supports the Swift Package Manager in version 2.x
  • ⚠️ Granola with 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 SAMKeychain should 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 Codable protocol.

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.

PSchmiedmayer avatar Apr 26 '22 13:04 PSchmiedmayer

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.

vishnuravi avatar Jul 07 '22 04:07 vishnuravi

This issue is being addressed in the new version of CardinalKit, which is based on Swift Package Manager: https://github.com/stanfordbdhg/cardinalkit

vishnuravi avatar Dec 24 '22 16:12 vishnuravi