SwiftyAcknowledgements
SwiftyAcknowledgements makes it easy to integrate acknowledgements for third party libraries into your iOS Apps.
Requirements
- iOS 9.0 or higher
- tvOS 9.0 or higher
- Xcode 14 or higher
Components
SwiftyAcknowledgements consists of two components.
Script
GenerateLicenseFileExe
is a Swift script that scans a directory for files containing the word license
and generates a property list containing the content of every license along with a name. The name will be set to the name of the folder that the corresponding license file is contained in.
Framework
SwiftyAcknowledgements comes with a framework SwiftyAcknowledgements.framework
that can be used to visualize the generated license file within an iOS App. The framework contains a TableViewController and a DetailViewController and can be integrated programatically or using a Storyboard.
Installation
Follow the instructions in the Carthage Documentation to install the built framework into your Xcode project.
Swift Package Manger
https://github.com/mredig/SwiftyAcknowledgements.git
Note: these urls will need to be updated if the PR is accepted.
Script
Paste this script into a run script phase in Xcode's build process.
SPM_CHECKOUT_SOURCES=$BUILD_DIR
# remove directories from path until `Build` is the parent directory
while [[ $(basename $SPM_CHECKOUT_SOURCES) != 'Build' ]]; do
echo $SPM_CHECKOUT_SOURCES
SPM_CHECKOUT_SOURCES=$(dirname $SPM_CHECKOUT_SOURCES)
done
# remove ONE more directory (Build)
SPM_CHECKOUT_SOURCES=$(dirname $SPM_CHECKOUT_SOURCES)
# SPM_CHECKOUT_SOURCES should NOW be the folder contained inside DerivedData that this project is being build in
# Append the path for SPM checkouts to finalize this variable
SPM_CHECKOUT_SOURCES="${SPM_CHECKOUT_SOURCES}/SourcePackages/checkouts"
cd $SPM_CHECKOUT_SOURCES/SwiftyAcknowledgements
exec -c swift run GenerateLicenseFileExe $SPM_CHECKOUT_SOURCES ${SRCROOT}/Carthage/Checkouts -o ${PROJECT_DIR}/Poop/Acknowledgements.plist
Note: The parameters for the script are the input directories that should be scanned for license files. The final argument should be -o
followed by the output file that should be generated by the script. Remove ${SRCROOT}/Carthage/Checkouts
if you're not using Carthage.
After that, build your project and add the generated license file to your Xcode project.
Usage
The framework contains AcknowledgementsTableViewController.swift
that can be pushed onto a UINavigationController
or presented modally. The AcknowledgementsTableViewController
will automatically look for a file Acknowledgements.plist
and display its contents. If your license file is named differently, you can specify your custom name using the property acknowledgementsPlistName: String
.
Customization
There are several ways you can customize the appearance of SwiftyAcknowledgements ViewControllers. The easiest possibility is to integrate using a storyboard and setting the provided IBInspectables on AcknowledgementsTableViewController. Using this method you can customize font sizes and the text for the table header and footer.
If you need additional customization options, you can always build a custom subclasses for the provided ViewControllers and override the desired methods.
Credits
SwiftyAcknowledgements was inspired by Vincent Tourraine's VTAcknowledgementsViewController.
License
SwiftyAcknowledgements is available under the MIT license. See the LICENSE file for more info.