Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/giginet/milepost
🚥 SwiftPM Build Plugin to show Git info on your app
https://github.com/giginet/milepost
Last synced: 2 months ago
JSON representation
🚥 SwiftPM Build Plugin to show Git info on your app
- Host: GitHub
- URL: https://github.com/giginet/milepost
- Owner: giginet
- License: mit
- Created: 2022-09-25T14:29:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-25T15:32:32.000Z (over 2 years ago)
- Last Synced: 2024-10-14T09:53:20.760Z (3 months ago)
- Language: Swift
- Homepage:
- Size: 682 KB
- Stars: 35
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Milepost
[![Build Status](https://img.shields.io/github/workflow/status/giginet/Milepost/Milepost?style=flat-square)](https://github.com/giginet/Milepost/actions?query=workflow%3AMilepost)
[![Language](https://img.shields.io/static/v1.svg?label=language&message=Swift%205.6&color=FA7343&logo=swift&style=flat-square)](https://swift.org)
[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-4BC51D.svg?style=flat-square)](https://swift.org/package-manager/)
[![Platform](https://img.shields.io/static/v1.svg?label=platform&message=iOS|macOS|watchOS|tvOS&color=grey&logo=apple&style=flat-square)](https://github.com/giginet/Milepost/blob/main/Package.swift)
[![License](https://img.shields.io/github/license/giginet/Milepost?&style=flat-square)](https://github.com/giginet/Milepost/blob/main/LICENSE.md)A Simple SwiftPM plugin to show Git commit on your apps
## Summary
**Milepost** is a simple library to fetch Git commit info.
You can show Git revisions for debug builds or production builds for end-users' inquiry.
This library provides [SwiftPM Build Tools Plugin](https://github.com/apple/swift-evolution/blob/main/proposals/0303-swiftpm-extensible-build-tools.md). It helps developers to integrate it easily.
## Installation
### 1. Integrate Milepost in your project with SwiftPM
- File > Add Packages...
- Enter `https://github.com/giginet/Milepost.git`
- Choose `Milepost` product### 2. Link Milepost in your application target
- Application Target > `General` > `Frameworks, Libraries, and Embedded Content` > `+`
- Choose `Milepost`### 3. Add build phases to fetch git info
- Application Target > `Build Phases` > `Run Build Tool Plug-ins` > `+`
- Choose `PrepareMilepost`
## Usage
You can fetch a latest revision with `RevisionLoader.load()`.
```swift
import Milepostlet revision = RevisionLoader.load()!
revision.hash
revision.branch
revision.shortHash
revision.lastCommit.author.description
revision.lastCommit.committer.description
revision.lastCommit.subject
revision.lastCommit.authorDate
revision.lastCommit.commitDate
```You can easily build a setting page like followings:
```swift
import SwiftUI
import Milepoststruct RevisionView: View {
var body: some View {
List {
Section {
if let revision = RevisionLoader.load() {
LabeledContent("Hash") {
Text(revision.hash)
.font(.caption)
}
LabeledContent("Short Hash") {
Text(revision.shortHash)
}
LabeledContent("Branch") {
Text(revision.branch ?? "-")
}
LabeledContent("Last Author") {
VStack(alignment: .trailing) {
Text(revision.lastCommit.author.name)
Text(revision.lastCommit.author.email)
.font(.caption)
}
}
LabeledContent("Commit Message") {
Text(revision.lastCommit.subject ?? "-")
}
}
} header: {
Text("Revision")
}
}
}
}
```## Requirements
|Users |Version|
|----------|----------|
|Developers|Xcode 14.0 or above and macOS 11.0 or above|
|App Users|any iOS, iPadOS, macOS, watchOS, tvOS|This plugin uses SwiftPM Build Tools Plugin. So you have to use Xcode 14.0 or above.
This feature is only required on a build process. Thus, this library runs on any platform versions.