{"id":14442844,"url":"https://github.com/BikeCalc/swift-measures","last_synced_at":"2025-08-27T14:30:49.637Z","repository":{"id":52485969,"uuid":"519022814","full_name":"BikeCalc/swift-measures","owner":"BikeCalc","description":"Swift package containing measurement types.","archived":false,"fork":false,"pushed_at":"2024-12-15T10:46:29.000Z","size":8027,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-18T23:57:20.479Z","etag":null,"topics":["ios","measurement-units","swift","swift-library","swift-package-manager"],"latest_commit_sha":null,"homepage":"https://bikecalc.github.io/swift-measures/documentation/measures/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BikeCalc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS.txt","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"alexandrehsaad"}},"created_at":"2022-07-28T23:38:17.000Z","updated_at":"2024-12-15T10:46:33.000Z","dependencies_parsed_at":"2024-03-22T01:23:54.476Z","dependency_job_id":"3e4d9b07-09cb-469a-a851-230aa4cc9934","html_url":"https://github.com/BikeCalc/swift-measures","commit_stats":null,"previous_names":["bikecalc/swift-measures"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/BikeCalc/swift-measures","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BikeCalc%2Fswift-measures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BikeCalc%2Fswift-measures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BikeCalc%2Fswift-measures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BikeCalc%2Fswift-measures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BikeCalc","download_url":"https://codeload.github.com/BikeCalc/swift-measures/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BikeCalc%2Fswift-measures/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272331184,"owners_count":24915661,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-27T02:00:09.397Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","measurement-units","swift","swift-library","swift-package-manager"],"created_at":"2024-08-31T21:01:11.364Z","updated_at":"2025-08-27T14:30:49.133Z","avatar_url":"https://github.com/BikeCalc.png","language":"Swift","funding_links":["https://github.com/sponsors/alexandrehsaad"],"categories":["Swift"],"sub_categories":[],"readme":"![](Assets/GitHubBanner.png)\n\n# swift-measures\n\nA package containing a set of objects and protocols to create and convert units of measure, for the Swift programming language.\n\n## Overview\n\nNo overview available.\n\n## Availability\n\n- iOS 13.0+\n- iPadOS 13.0+\n- macCatalyst 15.0+\n- macOS 10.15+\n- watchOS 6.0+\n\n## Installation\n\nThe Swift Package Manager is a tool for managing the distribution of Swift code and is integrated into the swift compiler.\n\n1. Add the package to the dependencies in your `Package.swift` file.\n\n    ```swift\n    let package: Package = .init(\n        ...\n        dependencies: [\n            .package(url: \"https://github.com/bikecalc/swift-measures.git\", branch: \"main\")\n        ],\n        ...\n    )\n    ```\n\n2. Add the package as a dependency on your target in your `Package.swift` file.\n\n    ```swift\n    let package: Package = .init(\n        ...\n        targets: [\n            .target(name: \"MyTarget\", dependencies: [\n                .product(name: \"Measures\", package: \"swift-measures\")\n            ]),\n        ],\n        ...\n    )\n    ```\n\n3. Import the package in your source code.\n\n    ```swift\n    import Measures\n    ```\n    \n## Demonstration\n    \n1. Create a dimension that conforms to the measurable protocol.\n\n\t```swift\n    struct FuelEfficiency: Measurable {\n        let coefficient: Double\n        let constant: Double\n        let symbol: String\n        \n        init(\n            coefficient: Double,\n            constant: Double = 0,\n            symbol: String\n        ) {\n            self.coefficient = coefficient\n            self.constant = constant\n            self.symbol = symbol\n        }\n        \n        static let base: Self = .kilometresPerLiter\n\t}\n\t```\n\n2. Create a minimum of two units.\n\n\t```swift\n    extension FuelEfficiency {\n        static let kilometresPerLiter: Self = .init(\n            coefficient: Length.kilometre.coefficient / Volume.liter.coefficient,\n            symbol: \"Km/L\"\n        )\n\n        static let metresPerLiter: Self = .init(\n            coefficient: Length.metre.coefficient / Volume.liter.coefficient,\n            symbol: \"m/L\"\n        )\n    }\n    ```\n\n3. Initialize a measure of your dimension with a value and unit.\n\n\t```swift\n    var measure: Measure\u003cFuelEfficiency\u003e = .init(5, .kilometresPerLiter)\n\t```\n\n4. Convert the measure to your other unit.\n\n    ```swift\n    measure.convert(to: .metresPerLiter)\n    print(measure) // Prints \"5000m/L\"\n\t```\n\n## Documentation\n\nYou can read more about this package by visiting the [documentation page].\n\n## Contribution\n\nContributions are what makes the open source community such an amazing place to learn, inspire, and create. If you wish to contribute and be part of this project, please fork the repository and create a [pull request].\n\n1. Fork the repository\n2. Create your feature branch `git checkout -b feature/NewFeature`\n3. Commit your changes `git commit -m 'Added a new feature'`\n4. Push to your branch `git push origin feature/NewFeature`\n5. Open a pull request\n\n### Reporting a bug\n\nIf you find a bug, please create an [issue].\n\n### Contacting the maintainers\n\nIf you want to share your thoughts on how to improve this repository, you can contact the code owner. See the `CODEOWNERS.txt` file for more information.\n\n### Supporting this repository\n\nIf this repository has been useful to you in some way, show your support by starring it.\n\n## Code of Conduct\n\nTo be a truly great community, we welcome developers from all walks of life, with different backgrounds, and with a wide range of experience. A diverse and friendly community will have more great ideas, more unique perspectives, and produce more great code. We will work diligently to make this community welcoming to everyone. See the `CODEOFCONDUCT.md` file for more information.\n\n## License\n\nDistributed under Apache License v2.0 with Runtime Library Exception. See the `LICENSE.md` file for more information.\n\n[documentation page]: https://bikecalc.github.io/swift-measures/documentation/measures\n[pull request]: https://github.com/bikecalc/swift-measures/pulls\n[issue]: https://github.com/bikecalc/swift-measures/issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBikeCalc%2Fswift-measures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBikeCalc%2Fswift-measures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBikeCalc%2Fswift-measures/lists"}