LicensePlist is a command-line tool that automatically generates a Plist of all your dependencies, including files added manually(specified by YAML config file) or using Carthage or CocoaPods. All these licenses then show up in the Settings app.
App Setting Root
License List
License Detail
Installation
Warning SPM(Swift Package Manager) are not supported.
CocoaPods (Recommended)
pod 'LicensePlist'
# Installation path: `${PODS_ROOT}/LicensePlist/license-plist`
Homebrew (Also Recommended)
brew install licenseplist
Mint (Also Recommended)
mint run mono0926/LicensePlist
Xcode project - SPM
In Project Settings, on the tab “Package Dependencies”, click “+” and add https://github.com/mono0926/LicensePlist.
Click “Add Package” without selecting any package products.
LicensePlist tries to find YourProjectName.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved and YourProjectName.xcworkspace/xcshareddata/swiftpm/Package.resolved, then uses new one.
The directory with cloned Swift package sources. If specified LicensePlist uses cloned files instead of GitHub API. For more information, see parameter -clonedSourcePackagesDirPath of xcodebuild.
By specifiying the path to the .xcodeprojLicensePlist will attempt to load the Package.resolved from that Xcode project. If you specify somedir/*.xcodeproj then LicensePlist will load from the first xcodeproj it finds in somedir.
--xcworkspace-path
Default: "*.xcworkspace"
By specifying the path to the .xcworkspaceLicensePlist will load the Package.resolved from that Xcode workspace. If you specify somedir/*.xcworkspace then LicensePlist will load from the first xcworkspace it finds in somedir.
--xcworkspace-path supersedes any provided --xcodeproj-path.
License file name variants for cloned Swift packages.
Case insensitive.
Supports any non-empty path extensions if FILENAME.* is specified.
Used only in combination with --package-sources-path.
--force
Default: false
LicensePlist saves latest result summary, so if there are no changes, the program interrupts.
In this case, execution time is less than 100ms for the most case, so you can run LicensePlist at Run Script Phase every time 🎉
You can run all the way anyway, by using --force flag.
--add-version-numbers
Default: false
When the library name is SomeLibrary, by adding --add-version-numbers flag, the name will be changed to SomeLibrary (X.Y.Z).
X.Y.Z is parsed from CocoaPods and Cartfile information, and GitHub libraries specified at Config YAML also support this flag.
--add-sources
Default: false
Adds the source of the library to the output if there is one. The source for GitHub and CocoaPods libraries is generated. Manual libraries use the optional source field.
--suppress-opening-directory
Default: false
Only when the files are created or updated, the terminal or the finder opens. By adding --suppress-opening-directory flag, this behavior is suppressed.
Automatically enabled if --sandbox-mode is specified.
--single-page
Default: false
All licenses are listed on a single page, not separated pages.
--fail-if-missing-license
Default: false
If there is even one package for which a license cannot be found, LicensePlist returns exit code 1.
--silence-mode / --verbose
By adding the --silence-mode flag, the logger’s output will not print.
The logger’s output will be more detailed than the average log level by adding the --verbose flag.
LicencePlist uses the latter option if you simultaneously set the --silence-mode option and the --verbose option.
Default: average log level
--no-color / --color
The logger’s output is printed in monochrome by adding the --no-color flag. If any escape characters in CI/CD log bother you, the --no-color option will help.
By adding the --color flag, LicensePlist will always print the logger’s output in color.
LicencePlist uses the latter option if you simultaneously set the --no-color option and the --color option.
If neither option is specified, LicensePlist will look for the NO_COLOR environment variable. If you set the NO_COLOR environment variable to "1", LicensePlist runs without colors.
Default: auto - LicensePlist decides its color mode depending on the terminal type.
--sandbox-mode / --no-sandbox-mode
Default: false
Enables or disables the “sandbox” mode.
In the sandbox mode, LicensePlist avoids network requests. That means Swift package licenses can not be fetched with GitHub API. To parse Swift package licenses --package-sources-path must be specified.
Integrate into build - run script
Add a Run Script Phase to Build Phases:
if [ $CONFIGURATION = "Debug" ]; then
/usr/local/bin/license-plist --output-path $PRODUCT_NAME/Settings.bundle --github-token YOUR_GITHUB_TOKEN
fi
Alternatively, if you’ve installed LicensePlist via CocoaPods the script should look like this:
if [ $CONFIGURATION = "Debug" ]; then
${PODS_ROOT}/LicensePlist/license-plist --output-path $PRODUCT_NAME/Settings.bundle --github-token YOUR_GITHUB_TOKEN
fi
In the project contextual menu click “GenerateAcknowledgementsCommand”.
The command dialog allows to specify command line arguments. Since Xcode doesn’t save the arguments for future use, it’s recommended to use a configuration file.
Click “Run” to run LicensePlist.
Click “Allow Command to Change files”. This action provides LicensePlist write access to your project directory.
“Don’t ask again” option prevents showing this dialog in the future.
Note: --package-sources-path option and packageSourcesPath config parameter are ignored by the command plugin.
Configuration
General options
The main parameters from the Options can be defined in the configuration file.
All the parameters are optional.
The tool uses the command line value if both the command line and the config specify values for the same attribute.
If you need to include a license that isn’t available on GitHub, you can place the license text in the config file to be included in the output.
The license text can also be read from a local file, to keep the config file clean.
Examples
License body directly in the config file:
manual:
- source: https://webrtc.googlesource.com/src
name: WebRTC
version: M61
body: |-
Copyright (c) 2011, The WebRTC project authors. All rights reserved.
...
...
...
Excludes can be defined to exclude matching libraries from the final output.
An exclude is a dictionary containing any combination of name, source, owner, or licenseType.
When using the dictionary format:
The exclusion rule is only applied if all properties match for a dependency. eg, (name: LicensePlist) AND (owner: mono0926)
Any property can be either a string or a regular expression.
Examples
Exclude a package by name:
exclude:
- name: LicensePlist
Exclude packages using a specific license:
exclude:
- licenseType: "Apache 2.0"
Exclude packages using any matching licenses:
exclude:
- licenseType: /BSD/
Exclude packages from a specific github owner:
exclude:
- owner: mycompany
Exclude packages from a specific github owner containing matching licenses:
exclude:
- owner: mycompany
licenseType: /^(?!.*MIT).*$/ # this regex excludes packages that do NOT use the MIT license
Exclude a package from a specific github owner and repo:
exclude:
- owner: mycompany
name: private-repo
Rename
If a library name is unsuitable for the output bundle, you can explicitly rename it. This can be used when a library name is too vague, or if more human-readable names are needed.
Examples
rename:
LicensePlist: License Plist # Rename LicensePlist to "License Plist"
WebRTC: Web RTC # Rename WebRTC to "Web RTC" (which is faulty, but used for test)
Q&A
How to generate Xcode project?
Execute swift package generate-xcodeproj or make xcode.
LicensePlistis a command-line tool that automatically generates a Plist of all your dependencies, including files added manually(specified by YAML config file) or usingCarthageorCocoaPods. All these licenses then show up in the Settings app.Installation
CocoaPods (Recommended)
Homebrew (Also Recommended)
Mint (Also Recommended)
Xcode project - SPM
In Project Settings, on the tab “Package Dependencies”, click “+” and add
https://github.com/mono0926/LicensePlist.Click “Add Package” without selecting any package products.
Download the executable binary from Releases
Download from Releases, then copy to
/usr/local/bin/license-plistetc.Or you can also download the latest binary and install it with a one-liner.
From Source
Clone the master branch of the repository, then run
make install.Usage
CartfileorPods, simply executelicense-plist.com.mono0926.LicensePlist.Outputdirectory will be generated.Settings.bundle.com.mono0926.LicensePlistas license list file on yourRoot.plist.Options
You can see options by
license-plist --help.--cartfile-pathCartfile--mintfile-pathMintfile--pods-pathPods--package-pathPackage.swiftLicensePlisttries to findYourProjectName.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolvedandYourProjectName.xcworkspace/xcshareddata/swiftpm/Package.resolved, then uses new one.--package-pathsPackage.swiftlicense-plist --package-paths /path/to/package1/Package.swift /path/to/package2/Package.swift--package-sources-pathLicensePlistuses cloned files instead of GitHub API. For more information, see parameter-clonedSourcePackagesDirPathof xcodebuild.license-plist --package-sources-path ./SourcePackages--xcodeproj-path"*.xcodeproj".xcodeprojLicensePlistwill attempt to load thePackage.resolvedfrom that Xcode project. If you specifysomedir/*.xcodeprojthenLicensePlistwill load from the firstxcodeprojit finds insomedir.--xcworkspace-path"*.xcworkspace".xcworkspaceLicensePlistwill load thePackage.resolvedfrom that Xcode workspace. If you specifysomedir/*.xcworkspacethenLicensePlistwill load from the firstxcworkspaceit finds insomedir.--xcworkspace-pathsupersedes any provided--xcodeproj-path.--output-pathcom.mono0926.LicensePlist.Output--output-path YOUR_PRODUCT_DIR/Settings.bundle--github-tokenreposcope is needed.LICENSE_PLIST_GITHUB_TOKENenvironment variable.--config-pathlicense_plist.yml--prefixcom.mono0926.LicensePlist--html-path--markdown-path--license-file-namesLICENSE, LICENSE.*.FILENAME.*is specified.--package-sources-path.--forceLicensePlistsaves latest result summary, so if there are no changes, the program interrupts.LicensePlistatRun Script Phaseevery time 🎉--forceflag.--add-version-numbersSomeLibrary, by adding--add-version-numbersflag, the name will be changed toSomeLibrary (X.Y.Z).X.Y.Zis parsed from CocoaPods and Cartfile information, and GitHub libraries specified at Config YAML also support this flag.--add-sources--suppress-opening-directory--suppress-opening-directoryflag, this behavior is suppressed.--sandbox-modeis specified.--single-page--fail-if-missing-license--silence-mode/--verbose--silence-modeflag, the logger’s output will not print.--verboseflag.--silence-modeoption and the--verboseoption.--no-color/--color--no-colorflag. If any escape characters in CI/CD log bother you, the--no-coloroption will help.--colorflag, LicensePlist will always print the logger’s output in color.--no-coloroption and the--coloroption.NO_COLORenvironment variable. If you set theNO_COLORenvironment variable to"1", LicensePlist runs without colors.--sandbox-mode/--no-sandbox-mode--package-sources-pathmust be specified.Integrate into build - run script
Add a
Run Script PhasetoBuild Phases:Alternatively, if you’ve installed LicensePlist via CocoaPods the script should look like this:
Integrate into build - build tool plugin
LicensePlist build tool plugins requires Swift package installation.
Select your target, on the tab “Build Phases”, in the section “Run Build Tool Plug-ins”, click “+” and add
LicensePlistBuildTool.In the case of using the build tool plugin, define all the settings in
license_plist.ymlat the root of your project.license_plist.ymlexample:Important: to process Swift Package licenses, the config must include one of the following parameters:
xcworkspacePath,xcodeprojPath,packagePaths.Note:
outputPathandpackageSourcesPathconfig parameters are ignored by the build tool plugin.See the configuration section for more information.
If you need to put license files to
Settings.bundleor any other specific place add the following script to build phases:Or in project contextual menu click “AddAcknowledgementsCopyScriptCommand” and select application target to create the build phase automatically.
Build the app. At the first run, Xcode asks a permission to run the plugin. Click “Trust & Enable All”
For unattended use (e.g. on CI), you can disable the package validation dialog by
-skipPackagePluginValidationtoxcodebuildordefaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation -bool YESfor that user.Note: This implicitly trusts all Xcode package plugins and bypasses Xcode’s package validation dialogs, which has security implications.
Contextual menu command
LicensePlist command requires Swift package installation.
In the project contextual menu click “GenerateAcknowledgementsCommand”.
The command dialog allows to specify command line arguments. Since Xcode doesn’t save the arguments for future use, it’s recommended to use a configuration file.
Click “Run” to run LicensePlist.
Click “Allow Command to Change files”. This action provides LicensePlist write access to your project directory.
“Don’t ask again” option prevents showing this dialog in the future.
Note:
--package-sources-pathoption andpackageSourcesPathconfig parameter are ignored by the command plugin.Configuration
General options
The main parameters from the Options can be defined in the configuration file.
All the parameters are optional.
The tool uses the command line value if both the command line and the config specify values for the same attribute.
Example
Manual GitHub source
A GitHub source can be explicitly defined to include the license in the scenario where it can’t be inferred from your dependency files.
Examples
Manual License Body
If you need to include a license that isn’t available on GitHub, you can place the license text in the config file to be included in the output. The license text can also be read from a local file, to keep the config file clean.
Examples
License body directly in the config file:
License body in local file:
Excludes
Excludes can be defined to exclude matching libraries from the final output. An exclude is a dictionary containing any combination of
name,source,owner, orlicenseType.When using the dictionary format:
(name: LicensePlist) AND (owner: mono0926)Examples
Exclude a package by name:
Exclude packages using a specific license:
Exclude packages using any matching licenses:
Exclude packages from a specific github owner:
Exclude packages from a specific github owner containing matching licenses:
Exclude a package from a specific github owner and repo:
Rename
If a library name is unsuitable for the output bundle, you can explicitly rename it. This can be used when a library name is too vague, or if more human-readable names are needed.
Examples
Q&A
How to generate Xcode project?
Execute
swift package generate-xcodeprojormake xcode.Related Articles
Stargazers over time
寄付(Donation)
Donations are welcome if you like LicensePlist🤗
Send Money by ウォレットアプリ Kyash