Git Product home page Git Product logo

licensegenerator-ios's Introduction

LicenseGenerator iOS

Build Version Swift Maintainability

Recursively finds all LICENSE.* files in a directory and generates a plist that can be displayed in Settings.bundle or the provided view controller.

Screenshot

The script can help ensure that the license section of your app is always up to date. Since it searches recursively the script works well with cocoapods projects.

Inspired by JosephH and Sean's comments on stackoverflow.

Build Script

The build script recursively searches the project for LICENSE files and generates a plist that can be used in a Settings.bundle. The script assumes that the parent directory of the LICENSE file is also the name of the library to be credited.

Usage

  • Copy credits.py to the your project root
  • Open your project, select your Target and select Build Phases
  • Add a new Run Script Phase after target dependencies
  • Add something like: ./credits.py -s "$SRCROOT" -o "$SRCROOT/Project/Settings.bundle/Credits.plist"
  • Build & profit

Excluding Directories

You can optionally tell the generator to ignore certain paths. To do so use the -e option and pass it a comma separated list of path fragments.

View Controller

If your app doesn't use a Settings.bundle you can use the provided view controller to show the licenses.

Installation

Add LicensesViewController to your Podfile:

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

pod 'LicensesViewController', '~> 0.10.0'

Then tell Pod to install it:

$ pod install

Grab credits.py from this repo and add it to your project.

Usage

Add the build script as described above and make sure the resulting plist is included in the app target.

import LicensesViewController

// ...

let licensesController = LicensesViewController()
licensesController.loadPlist(Bundle.main, resourceName: "Credits")

// ...

Example Project

git clone https://github.com/carloe/LicenseGenerator-iOS.git
cd LicenseGenerator-iOS/Example
pod install
open LicensesViewControllerExample.xcworkspace

Requirements

  • iOS 8.0
  • tvOS 9.0
  • Swift 4.2, 5.0, 5.1, 5.2

If you depend on Python 2.x use '~> 0.9.0' in your Podfile.

If you are targeting Swift 4.0 use '~> 0.6.6' in your Podfile.

Contact

Twitter: @carloeugster Email: [email protected]

License

MIT

licensegenerator-ios's People

Contributors

bryant1410 avatar carloe avatar colejd avatar davidkraus avatar farktronix avatar levibostian avatar mobinzk avatar owenworley avatar stephsharp avatar tghs avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

licensegenerator-ios's Issues

Can you please clarify what you mean by "make sure the resulting plist is included in the app target"?

Nothing appears in the LicensesViewController, and it seems like Credits.plist cannot be loaded properly.
I suspect it's because I didn't do anything in particular to include Credits.plist in the target. Settings.bundle has the target box checked in Target Membership inspector, but there is no checkbox for Root.plist or Credits.plist under it.
So can you please clarify what you mean by "make sure the resulting plist is included in the app target"?

Wrong title when Licence file is not in root folder

When the licence file of the pod is in a directory that is not named after the pod (e.g. not in the root, instead in a subfolder called "foo") you get the wrong title (in this case: "foo").
The actual line of code can be found in credits.py:

title = path.split("/")[-2]

This just takes the parent of the licence file as title.

Example pod where it fails:

  • App Center

Expected Behavior: Title should be "AppCenter"

Actual Behavior: Title is "iOS" (because the parent folder of Licence file is "iOS")

Regression: Allow access from Objective-C

I have a mixed Objective-C and Swift project using LicensesViewController which I have just updated to Swift 4 from Swift 3

However this does now not compile because Objective-C code cannot see open func loadPlist(_ bundle: Bundle, resourceName: String). Swift 4 requires explicitly declaring @objc to functions which are exposed to Objective-C.

Could you please add @objc to the functions you wish to expose to Objective-C.

IPhone X support

Default implementation of the LicensesViewController doesn't respect safe area of the view and when you scroll through data it overlaps interactive controls at the very bottom of the screen. I believe the updateViewConstraints() needs to be updated per ios 11.

Ordering of licenses?

Hey, I really like this :). It lets me include licenses for both code libraries and graphics assets. I've got it working in a production app from my last job! One thing I wonder about though-- what defines the ordering of licenses in the Settings bundle? e.g., in this

SwiftyJSON comes before Alamofire in the list not after as I might expect.

Would you be open to a PR that enables some different sort order? E.g., alphabetic?

Thanks,
Chris.

No python in macOS 12.3

As there is no python in macOS 12.3 the current script is not working.
Any ideas how to fix this, beside installing our own python 2.x and changing the path?

Cant run on MacOS Ventura 13.0.1

When I try to build the app I get:

credits.py: /usr/bin/python: bad interpreter: No such file or directory

I've installed python but due to system integration protection or something I cannot link it to /usr/bin/python.
Do you know of any fix for this?

Thanks

How to

I suggest placing quotes in the how-to doc around $SRCROOT. Directory spaces will kill the command line and cause Xcode builds to fail.

Command PhaseScriptExecution failed with a nonzero exit code

Upon running I get the following build error:

/Users/georgedendle/Library/Developer/Xcode/DerivedData/GYM_AMIGO-czcrxvthuppywdaoiqdvgzsunpsy/Build/Intermediates.noindex/GYM AMIGO.build/Debug-iphoneos/GYM AMIGO.build/Script-FDFA256422CBC3C30037637F.sh: line 2: ./credits.py: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code

This is my run script code
./credits.py -s "$SRCROOT" -o "$SRCROOT/Project/Settings.bundle/Credits.plist"

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.