From e1b7f020ff2c4a48d0ed751ab77e602c7286b0e3 Mon Sep 17 00:00:00 2001 From: Sam Spencer Date: Fri, 29 May 2020 17:06:54 -0400 Subject: [PATCH] Added Support for SPM --- README.md | 25 ++++++++++++++++++++++++- ackack.py | 11 +++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f31327a..f3e0f19 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # AckAck -AckAck is a python script that automatically generates a plist based on the licenses in your Carthage or CocoaPods folder. When you use the plists in your app, the licenses will show up in the Settings app. +AckAck is a python script that automatically generates a plist based on the licenses in your Carthage, CocoaPods, or SwiftPackageManager folder. When you use the plists in your app, the licenses will show up in the Settings app. ![Settings example](http://i.imgur.com/V4JfPlC.png) @@ -45,3 +45,26 @@ You can see the options and other help information by running `./ackack.py --hel cd $SRCROOT ./ackack.py ``` + +### Using with Swift Package Manager +Things get a little trickier when using SPM because of how Xcode stores the packages. If you plan to integrate with Xcode, set your Run Script Build Phase like so: + +```sh +DERIVED_DATA_CANDIDATE="${BUILD_ROOT}" +while ! [ -d "${DERIVED_DATA_CANDIDATE}/SourcePackages/checkouts" ]; do + if [ "${DERIVED_DATA_CANDIDATE}" = / ]; then + echo >&2 "error: Unable to locate SourcePackages directory from BUILD_ROOT: '${BUILD_ROOT}'" + exit 1 + fi + + DERIVED_DATA_CANDIDATE="$(dirname "${DERIVED_DATA_CANDIDATE}")" +done + + +cd $SRCROOT +./ackack.py --spminput ${DERIVED_DATA_CANDIDATE} +``` + +Otherwise, you'll need to specify the `--spminput` argument when running AckAck. SPM contents (unless you've specified otherwise) are located in your app's derived data folder under `/SourcePackages/checkouts`. The path to that folder usually looks something like this: + + /Users/username/Library/Developer/Xcode/DerivedData/AppName-buildUUID/SourcePackages/checkouts diff --git a/ackack.py b/ackack.py index b171ae5..029c580 100755 --- a/ackack.py +++ b/ackack.py @@ -10,7 +10,7 @@ from argparse import ArgumentParser -VERSION = '4.1' +VERSION = '4.2' # Configure the logger @@ -41,7 +41,9 @@ def find_input_folders(self): input_folders.append(carthage_folder) if cocoapods_folder: input_folders.append(cocoapods_folder) - + if self.options.spm_folder: + input_folders.append(self.options.spm_folder) + self.options.input_folders = input_folders def find_output_folder(self): @@ -251,6 +253,11 @@ def main(): help='the path to the input folder(s), e.g. Carthage/Checkouts' ) + parser.add_argument( + '-s', '--spminput', dest='spm_folder', + help="the path to the app's derived data folder pointing to source packages and checkouts, eg. ${DERIVED_DATA_CANDIDATE}/SourcePackages/checkouts/" + ) + parser.add_argument( '-o', '--output', dest='output_folder', help='the path to the output folder, e.g. MyProject/Settings.bundle'