GithubHelp home page GithubHelp logo

swiftpackageacknowledgement's Introduction

SwiftPackageAcknowledgement

Creates a PLIST file out of a Swift Package Manager resolved JSON, including its GitHub license. The PLIST can then be used by your app to show the third-party libraries included in your app, by using one of the many Acknowledgement ViewControllers available for CocoaPods, such as https://github.com/vtourraine/AcknowList which is the one this script was tested with.

Because this script's output matches perfectly the one from CocoaPods, you can merge both PLISTs into one and have your Acknowledgement screen showing all the dependencies you use in your app either if they come from SPM or Pods.

The license is fetched from GitHub and the unauthenticated API limit is around 60 requests per hour. If this is not enough for you, this script supports OAuth Client credentials, so you can register your own GitHub application and call this script using your ClientID and ClientSecret and increase the limits to about 5000 per hour.

To register a GitHub application please follow this link: https://github.com/settings/developers

How to use

Without GitHub token

> swift run spm-ack generate-plist ~/MyProject/MyProject.xcworkspace ~/MyProject/Resources/SwiftPackageManager.plist

With GitHub token

> swift run spm-ack generate-plist ~/MyProject/MyProject.xcworkspace ~/MyProject/Resources/SwiftPackageManager.plist MyClientID MyClientToken

Future plans

Instead of using CocoaPods PLIST as output, we plan to have our own JSON and allow this script to also convert CocoaPods PLIST into this JSON format. The benefit is allowing more information to be stored in the JSON, such as GitHub etag to avoid fetching when this is not needed. The drawback is that this will break compatibility with other Acknowledgement ViewControllers implementations, and we'll need to provide a new one. To avoid that, when this is implemented, both options will be available for you to choose.

Also it's planned to support other SPM sources such as BitBucket or GitLab, but this is not our first priority at this point, so please feel free to contribute in case this is useful for you.

swiftpackageacknowledgement's People

Contributors

luizmb avatar lukasliebl avatar melle avatar mltbnz avatar oguzyuuksel avatar pixyzehn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

swiftpackageacknowledgement's Issues

Support Package.resolved V2

First off, thanks for this great library!

The Package.resolved format has changed since Xcode 13.3. The new format no longer has an object wrapper, and some of the field names have changed. It looks like this:

{
  "pins" : [
    {
      "identity" : "alamofire",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/Alamofire/Alamofire",
      "state" : {
        "revision" : "f82c23a8a7ef8dc1a49a8bfc6a96883e79121864",
        "version" : "5.5.0"
      }
    },
  ],
  "version" : 2
}

I began working on a proof of concept for this that implements the new json format. It works, but drops support for V1 of Package.resolved. I got stuck with some of the functional libraries being used and wasn't sure how to best fit in support for both Package.resolved formats.

I think it could work by adding a new Decodable type that represents the new Package.resolved format (ResolvedPackageV2 in my above linked code), and then introduce an internal type, say, PackageInternal, that can be initialized by either ResolvedPackage or ResolvedPackageV2. That way World doesn't depend on the json structure (ResolvedPackage) like it does now.

We could attempt to decode the json using both formats and only throw an error if both fail. Something like:

func getInternalPackage(from data: Data) -> Result<InternalPackage, SomeError> {
    if let packageV1 = try? JSONDecoder().decode(ResolvedPackageContent.self, from data) {
        return .success(InternalPackage(package: packageV1))
    }

    if let packageV2 = try? JSONDecoder().decode(ResolvedPackageContentV2.self, from data) {
        return .success(InternalPackage(packageV2: packageV2))
    }

    return .failure(.couldNotDecodeJson)
}

The above could be improved, but hopefully it helps illustrate the idea.

Let me know your thoughs and if you have any guidance for how this might fit into the current code. I'm new to the concept of having a World struct and functions like contramapEnvironment() :)

Bus error: 10

I am often, but not consistently, getting a "Bus error: 10" when running this script.

For what it's worth, it appears that the last Swift package gives a warning. I don't know if this is related:

โš ๏ธ Ignoring project brightcove-player-sdk-ios becuse we failed to download the LICENSE from github. Error: githubLicenseNotFound

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.