Code Monkey home page Code Monkey logo

ackgen's Introduction

AckGen

Simple Acknowledgements Generator for SPM package license information.

Overview

AckGen automatically generates a plist file containing the title and license information for all Swift packages used in your project.
This can be used to feed a SwiftUI List or UITableView dataSource in your app.

Requirements

  • Xcode 12+ (tested with 12.5)

Installation

  1. Add AckGen as a dependency for your project in Xcode.

Warning Leave the checkbox for executable unchecked

  1. Add the following as a Run Script for your target in Xcode
DIR=$PROJECT_TEMP_DIR/../../../SourcePackages/checkouts/AckGen
if [ -d "$DIR" ]; then
  cd $DIR
  SDKROOT=(xcrun --sdk macosx --show-sdk-path)
  swift run ackgen
else
  echo "warning: AckGen not found. Please install the package via SPM (https://github.com/MartinP7r/AckGen#installation)"
fi

If you want the plist file to be saved somewhere other than Acknowledgements.plist at the root of your project ($SRCROOT/Acknowledgements.plist), you can provide a custom path as the first command line argument to ackgen above.

  swift run ackgen $SRCROOT/PackageLicenses.plist
  1. Add the generated plist file to your project if you haven't already.
    Make sure to remove the check for Copy items if needed

  2. You can now simply use the plist file however you like or use the Acknowledgement model for convenience:

import AckGen
// ...
let acknowledgements: [Acknowledgement] = Acknowledgement.all()
acknowledgements.forEach { print($0.title, $0.license) }

UI

Optionally, there's a basic SwiftUI AcknowledgementsList component (see gif above) included in the AckGenUI module that you can use to quickly create a generic list of acknowledgements to embed into a NavigationView.

import AckGenUI
import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationView {
            AcknowledgementsList()
        }
    }
}

Beta

Until 1.0 is reached, minor versions will be breaking.

Contribution

This is my first stab at building a Swift package and was mainly intended to be an exercise.
I hope, however, that it can be useful to someone other than me.

If you encounter any problems or have suggestions, additions or possible improvements to share, you are more than welcome to open a PR or issue and I'll get back to you as soon as my time allows it.

TODO

  • Add non-SPM licenses separately
  • Add UI components (SwiftUI List with NavigationLink to license info?)
  • Allow Run Script Output Files as alternative to command line argument
  • Allow to specify excluded packages
  • Add tests
  • Add other platforms

ackgen's People

Contributors

dabodamjan avatar martinp7r avatar mattkiazyk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.