A command-line tool to generate a JSON-list of all used SPM-dependencies of an Xcode-project.

Overview

SwiftPackageList

Version License Tweet

A command-line tool to generate a JSON-list of all used SPM-dependencies of an Xcode-project.

This includes all the Package.resolved informations and the license from the checkouts. Additionally there is a Swift Package to read the generated package-list.json from the application's bundle.

Command-Line Tool

Installation

Clone or download this repository and execute the install script with sudo sh install.sh. After that you can run the swift-package-list command in your terminal.

There is also an uninstall script for convenience.

Usage

Open the terminal and run swift-package-list with the directory to the .xcodeproj-file you want to generate the list from.

In addition to that you can specify the following options:

Option Description
-d, --derived-data-path The directory to your DerivedData-folder. (default: ~/Library/Developer/Xcode/DerivedData)
-o, --output-path The path where the package-list.json-file will be stored. (default: ~/Desktop)
--requires-license Will skip the packages without a license-file.
--version Show the version.
-h, --help Show help information.

Run Script Phase

You can easily set up a Run Script Phase in your target of your Xcode-project to keep the package-list.json up to date automatically:

  1. open the corresponding target and click on the plus under the Build Phases section
  2. select New Run Script Phase and add the following script into the code box:
# creates/updates package-list.json on every build

if type swift-package-list &> /dev/null; then
    output_path=${PRODUCT_SETTINGS_PATH%/Info.plist}
    swift-package-list $PROJECT_FILE_PATH --output-path $output_path --requires-license
else
    echo "warning: swift-package-list not installed"
fi
  1. optionally you can rename the Phase by double-clicking on the title
  2. build your project (cmd + b)
  3. right-click on the targets-folder in the sidebar and select Add Files to " "
  4. select package-list.json in the Finder-window

The package-list.json-file will be updated now on every build and can be opened from the bundle in you app. You can do that manually or use the package for that (as follows).

Swift Package

Load package-list.json from the bundle with a single function call.

Requirements

  • macOS 10.10+
  • iOS 9.0+
  • tvOS 9.0+
  • watchOS 2.0+

Usage

Add the package to your project as shown here.

Now you can retrieve the packages from the file like this:

import SwiftPackageList

do {
    let packages = try packageList()
    // use packages
} catch PackageListError.noPackageList {
    print("There is no package-list.json file")
} catch {
    print(error)
}

License

SwiftPackageList is available under the MIT license. See the LICENSE file for more info.

Comments
  • Build phase - Build input files cannot be found

    Build phase - Build input files cannot be found

    Hi,

    I added the SPM, added the executable and the ui...

    I assumed I didn't have to install (Aka using mint) as I used the SPM ?

    Added the build phase and I'm getting this error...

    error: Build input files cannot be found: '/Users/jm/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos/ArgumentParser.o', '/Users/jm/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos/ArgumentParserToolInfo.o' (in target 'swift-package-list' from project 'SwiftPackageList')

    Any ideas ?

    Thanks,

    Jules.

    help wanted 
    opened by JulesMoorhouse 13
  • SwiftPackageListUI AcknowledgmentsList() - shows no licenses

    SwiftPackageListUI AcknowledgmentsList() - shows no licenses

    Hi,

    Sorry to be so much trouble....

    However, I have a package-list.plist with licenses in it..

    But nothing showing in the UI.

    image

    I don't think I can see any logs on the Xcode debug..

    Any ideas?

    Jules.

    help wanted 
    opened by JulesMoorhouse 8
  • Build script phase not working

    Build script phase not working

    First of all, thank you for making this! It works beautifully when I run it from the terminal!

    Unfortunately, I have not been able to get it to work as a build script phase. I installed swift-package-list on my machine beforehand, but it still doesn't work. I also tried adding it as a package dependency to my project, but that also didn't work. Either way it gives the warning "swift-package-list not installed". I am just using an xcodeproj, not xcworkspace. I'm happy to give any additional details that might be helpful. Thank you!

    help wanted 
    opened by eschos24 4
  • No such module 'AppKit'

    No such module 'AppKit'

    Hi,

    I have an iOS project and am using the AcknowledgmentsList from SwiftPackageListUI.

    I've selected the ..

    SwiftPackageListUI
    Swift-Package-List
    

    .. spm packages...

    However, I'm getting an error from the PDFBuilder

    image

    As the error mentions, think it needs and if statement etc...

    Jules.

    help wanted 
    opened by JulesMoorhouse 3
  • Question re. swift-package-list

    Question re. swift-package-list

    I have updated SwiftPackageList to 1.4.0. This caused a package called swift-argument-parser v1.0.3 to get added to the SPM. Is this OK?

    Following the new instructions, I downloaded project and ran make update and received the following error:

    sh uninstall.sh
    sh: uninstall.sh: No such file or directory
    make: *** [update] Error 127
    

    Thought I would try uninstall and install:

    make uninstall returns rm -f "/usr/local/bin/swift-package-list"

    make install returns the following:

    swift build --configuration release
    Fetching https://github.com/apple/swift-argument-parser from cache
    Fetched https://github.com/apple/swift-argument-parser (0.57s)
    Computing version for https://github.com/apple/swift-argument-parser
    Computed https://github.com/apple/swift-argument-parser at 1.0.3 (0.62s)
    Creating working copy for https://github.com/apple/swift-argument-parser
    Working copy of https://github.com/apple/swift-argument-parser resolved at 1.0.3
    [13/13] Build complete!
    cp -f ".build/release/SwiftPackageListCommand" "/usr/local/bin/swift-package-list"
    cp: .build/release/SwiftPackageListCommand: No such file or directory
    make: *** [install] Error 1
    

    Am I doing something wrong?

    opened by gaw3 3
  • Feature request: Support for -clonedSourcePackagesDirPath

    Feature request: Support for -clonedSourcePackagesDirPath

    First of all, love this software :)

    If I run xcodebuild -resolvePackageDependencies with an additional argument of -clonedSourcePackagesDirPath ~/Packages swift-package-list cannot find the workspace-state.json.

    Enhancement

    In addition to --derived-data-path can you also provide an alternative --source-packages-data-path to override this?

    Rationale

    • Some CI scenarios benefit from clearing derived data, so xcodebuild provides the ability to resolve packages to a different location.

    Is this a feature you could add, please?

    enhancement 
    opened by notapplicableio 2
  • Build Package.resolved version system

    Build Package.resolved version system

    Xcode 13.3 introduced a new Package.resolved version (2). The entire object structure has changed (as shown in #19) and we need a system to support version 1, 2 and any upcoming versions. Version 2 gets also rid of the package name... we have to switch to the last path component of the repository URL (which is not ideal but better than the new identity parameter).

    enhancement 
    opened by FelixHerrmann 0
  • Dependency Tree is missing

    Dependency Tree is missing

    The Swift Package Manager can show you a Dependency-Tree. But that works only on packages directly, not on projects. So you can never see a Dependency-Tree for your project.

    If this tool could build a Depdency-Tree for your project, that would be fantastic.

    I build a script for that, but having it in your tool would be better, especially since I don't have your experience and am not 100% sure if that's 100% resistent against edge-cases:

    if [[ $1 == "" ]]; then
      echo "Missing build dir as 1st parameter"
      exit 1
    fi
    
    if [[ $2 == "" ]]; then
      echo "Missing project dir as 2nd parameter"
      exit 1
    fi
    
    BUILD_DIR=$1
    PROJECT_DIR=$2
    
    echo "Build dependencies tree"
    cd "$BUILD_DIR/../../SourcePackages/checkouts"
    exportFile="$PROJECT_DIR/dependencies-tree.md"
    echo "# Dependencies trees for each Swift-Package" > "$exportFile"
    echo "" >> "$exportFile"
    echo "Build date: $(date '+%Y-%d-%m %a %H:%M:%S %Z')" >> "$exportFile"
    echo "" >> "$exportFile"
    for directory in */; do
      echo "Tree for $directory"
      echo "" >> "$exportFile"
      echo "## Tree for $directory" >> "$exportFile"
      pushd $directory
      swift package show-dependencies >> "$exportFile"
      echo "" >> "$exportFile"
      echo "" >> "$exportFile"
      popd
    done
    
    opened by JD-CSTx 1
  • Feature Request: add `LicenseName` field to the output

    Feature Request: add `LicenseName` field to the output

    I want to start with saying: I love this software! Thanks for creating it!

    I was wondering if there is an easy way to add the license name as a field to the output? The output files right now have a license file with the raw text of the license, but I was wondering if you would be open to add the licenseName, in the form of an SPDX license identifier to the output as well?

    Background: In our software attributions list, we list all the included components, their name, version and license identifier. Then, when one clicks on a license, the full text appears, but we first want to start by showing just the license identifier.

    In our use case we are using the json output of the package list.

    opened by mmaetzler 5
Releases(2.1.2)
  • 2.1.2(Dec 3, 2022)

  • 2.1.1(Aug 28, 2022)

  • 2.1.0(Jul 7, 2022)

    What's Changed

    • source packages path option by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/42

    Full Changelog: https://github.com/FelixHerrmann/swift-package-list/compare/2.0.1...2.1.0

    Source code(tar.gz)
    Source code(zip)
  • 2.0.1(Jun 24, 2022)

  • 2.0.0(May 18, 2022)

    What's Changed

    • customfilename option by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/33
    • splpackagelist returning nil by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/34
    • restructure command target by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/36
    • unit testing by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/38
    • configure ci by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/40

    Full Changelog: https://github.com/FelixHerrmann/swift-package-list/compare/1.6.0...2.0.0

    Source code(tar.gz)
    Source code(zip)
  • 1.6.0(Apr 11, 2022)

    What's Changed

    • Felix/pdf by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/26

    Full Changelog: https://github.com/FelixHerrmann/swift-package-list/compare/1.5.0...1.6.0

    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Apr 9, 2022)

    What's Changed

    • Felix/settings bundle by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/23
    • Felix/important languages by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/24

    Full Changelog: https://github.com/FelixHerrmann/swift-package-list/compare/1.4.1...1.5.0

    Source code(tar.gz)
    Source code(zip)
  • 1.4.1(Mar 15, 2022)

    What's Changed

    • Felix/improve error handling by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/18
    • Felix/packageresolved version system by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/21

    Full Changelog: https://github.com/FelixHerrmann/swift-package-list/compare/1.4.0...1.4.1

    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Mar 7, 2022)

    What's Changed

    • Felix/swiftui UI by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/11
    • Felix/mint by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/13
    • Felix/makefile by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/15

    Full Changelog: https://github.com/FelixHerrmann/swift-package-list/compare/1.3.0...1.4.0

    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Mar 6, 2022)

    What's Changed

    • Felix/xcode workspaces by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/9

    Full Changelog: https://github.com/FelixHerrmann/swift-package-list/compare/1.2.0...1.3.0

    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Feb 28, 2022)

    What's Changed

    • Felix/uikit UI by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/6
    • Felix/objective c by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/7

    Full Changelog: https://github.com/FelixHerrmann/swift-package-list/compare/1.1.0...1.2.0

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Feb 26, 2022)

    What's Changed

    • Felix/plist option by @FelixHerrmann in https://github.com/FelixHerrmann/swift-package-list/pull/5

    New Contributors

    • @FelixHerrmann made their first contribution in https://github.com/FelixHerrmann/swift-package-list/pull/5

    Full Changelog: https://github.com/FelixHerrmann/swift-package-list/compare/1.0.2...1.1.0

    Source code(tar.gz)
    Source code(zip)
  • 1.0.2(Feb 19, 2022)

  • 1.0.1(Dec 14, 2021)

  • 1.0.0(Nov 3, 2021)

    • Command-Line tool to create list
    • Swift Package to read list

    Full Changelog: https://github.com/FelixHerrmann/swift-package-list/commits/1.0.0

    Source code(tar.gz)
    Source code(zip)
Owner
Felix Herrmann
Swift, SwiftUI and UIKit Developer
Felix Herrmann
The best command-line tool to install and switch between multiple versions of Xcode.

The best command-line tool to install and switch between multiple versions of Xcode.

Robots and Pencils 2.3k Jan 9, 2023
A command-line tool to sort Xcode's `.xcodeproj` file.

XcodeProjSorter A command-line tool to sort Xcode's .xcodeproj file. It sorts following sessions: PBXGroup PBXResourcesBuildPhase PBXSourcesBuildPhase

Nelson 7 Apr 27, 2022
A command line tool to easily install and browse Xcode templates

?? XTrail A command line tool to easily install and browse Xcode templates. Usage The general invocation syntax for xtrail is as follows: xtrail <subc

Shogo Sakaue 3 Dec 16, 2021
A command line tool that calls your Xcode Test Plan and creates screenshots of your app automatically.

ShotPlan (WIP) A command line tool that calls your Xcode Test Plan and creates screenshots of your app automatically. ShotPlan will also take care of

Devran Cosmo Uenal 6 Jul 21, 2022
Command line utility to create a list of installed iOS simulators, for use with SwiftUI previews.

Installed-simulators - Command line utility to create a list of installed iOS simulators, for use with SwiftUI previews.

Casey Liss 18 Aug 19, 2022
A Mac command-line tool that generates kick-ass Jamf Pro reports.

KMART - Kick-Ass Mac Admin Reporting Tool A command-line utility generating kick-ass Jamf Pro reports: Features Reporting on the following Jamf Pro ob

Nindi Gill 86 Dec 15, 2022
ipatool is a command line tool that allows you to search for iOS apps on the App Store and download a copy of the app package, known as an ipa file.

ipatool is a command line tool that allows you to search for iOS apps on the App Store and download a copy of the app package, known as an ipa file.

Majd Alfhaily 3k Dec 30, 2022
iOS command-line tool that allows searching and downloading ipa files from the iOS App Store

ipatool for iOS This is a port of Majd Alfhaily's ipatool adapted to run on iOS Build / Installation To build this, make sure you have AppSync install

dan 21 Sep 13, 2022
A nifty command-line tool to customize macOS icons

iconset A nifty command line tool to manage macOS icons iconset is a new command line tool for macOS that allows you to change icons for macOS apps (e

aarnav tale 32 Nov 17, 2022
🕳 A simple command line tool to punch hole to reduce disk usage on APFS volume for such as a raw disk image.

HolePunch NAME holepunch -- A simple command line tool to punch hole to reduce disk usage on APFS volume for such as a raw disk image. SYNOPSIS holepu

Yoshimasa Niwa 15 Nov 24, 2022
Command Line Tool for interacting with MachO binaries on OSX/iOS

inject inject is a tool which interfaces with MachO binaries in order to insert load commands. Below is its help. ➜ ./inject -h OVERVIEW: inject v1.0.

<script>alert('1')</script> 36 Dec 23, 2022
CookCLI is provided as a command-line tool to make Cook recipe management easier

CookCLI is provided as a command-line tool to make Cook recipe management easier, and enable automation and scripting workflows for the CookLa

null 523 Dec 29, 2022
A Mac command-line tool that automatically downloads macOS Installers / Firmwares.

MIST - macOS Installer Super Tool A Mac command-line tool that automatically downloads macOS Installers / Firmwares: Features List all available macOS

Nindi Gill 483 Jan 8, 2023
macOS command line tool to return the available disk space on APFS volumes

diskspace Returns available disk space With the various APFS features the value for free disk space returned from tools such as du or df will not be a

Armin Briegel 131 Nov 14, 2022
A powerful command line tool for performing stoichiometry calculations on checmicals and chemical equations.

Stoichiometry Stoichiometry is a powerful command line tool for preforming stoichiometry chemicals and chemical equations. Its subcommands are listed

null 3 Jul 15, 2022
Josephus - A command line tool to solve Josephus problem in Swift

josephus A command line tool to solve Josephus problem in Swift

Masahiro Oono 0 Jan 25, 2022
A command line profiling tool with stopwatch, cpu and memory usage

timeui A command line profiling tool with stopwatch, cpu and memory usage. Usage ./timeui path/to/app-to-profile runs the stopwatch and signpost regio

Marin Todorov 107 Dec 10, 2022
Mac App Store: Embedding a Command Line tool using paths as arguments

Mac App Store: Embedding a Command Line tool using paths as arguments Code snippets to embed a Command Line tool using paths as arguments on the Mac A

Alexandre Colucci 10 Aug 20, 2022
RsyncOSX and RsyncUI are GUI´s on the Apple macOS plattform for the command line tool rsync

Hi there ?? RsyncOSX and RsyncUI are GUI´s on the Apple macOS plattform for the command line tool rsync. It is rsync which executes the synchronize ta

Thomas Evensen 1.1k Dec 23, 2022