Coder Social home page Coder Social logo

combes / credits Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 1.97 MB

Encapsulate third party license attributions for iOS projects.

License: MIT License

Swift 85.31% HTML 7.51% Ruby 4.00% Objective-C 3.17%
attributions credits swift third-party ios xcode cocoapods license license-management

credits's Introduction

Credits

A simple way to display third-party attributions in an iOS project.

Animated gif

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate Credits into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
pod 'Credits'
end

Then, run the following command:

$ pod install

Be sure to add a "Copy Framework" step in Xcode > Project > Target > Build Phases alt text

Example

See the included example for how to instantiate, but this is a simple example:

// Load plist file in an array for the parser to use
let licensePath = Bundle.main.path(forResource: "licenses", ofType: "plist")
// Create a new license parser
let parser = LicenseParser(licensePath: licensePath!)
// Create a new Credits view controller
let controller = CreditsViewController.creditsViewController(parser: parser!)
present(controller, animated: true, completion: nil)

License Property List Format

The license file must be a Property List using the following format:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>title</key>
<string>SomeThirdPartyLibraryTitle</string>
<key>link</key>
<string>https://github.com/SomeThirdPartyLibraryTitle</string>
<key>content</key>
<string>Copyright (c) 2014-2016... (rest of license contents)
</string>
</dict>
</array>
</plist>

title is replaced by the title of the third-party project.

link is a link to whereever the project is (e.g. GitHub).

content is the license file content.

Custom HTML

You can load custom body and content HTML for display in the web view as follows:

// Custom body and content HTML
let bodyHTMLPath = Bundle.main.path(forResource: "license-body", ofType: "html")
let contentHTMLPath = Bundle.main.path(forResource: "license-content", ofType: "html")
let parser = LicenseParser(licensePath: licensePath, licenseHTMLBodyPath: bodyHTMLPath, licenseHTMLContentPath: contentHTMLPath)

The body HTML must contain the flagged variable $CONTENT which is replaced by the parsed license file content.

<!DOCTYPE html>
<html lang="en">
<body>
<div>
The following sets forth attribution notices for third party software that may be contained in portions of this product.
</div>
$CONTENT
</body>
</html>

The content HTML (for each individual license) contains three flags as shown in the example:

<div class="license-title">
$TITLE
<div class="license-link">$LINK</div>
</div>
<div class="license-content">
$CONTENT <!-- Wrap each license in <p></p> for proper formatting -->
</div>

$TITLE is replaced by the title of the third-party project.

$LINK is a link to whereever the project is (e.g. GitHub).

$CONTENT is the license file content.

License

Credits is released under the MIT license. See LICENSE for details.

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.