{"id":13496817,"url":"https://github.com/FelixHerrmann/swift-package-list","last_synced_at":"2025-03-28T19:31:08.276Z","repository":{"id":38473803,"uuid":"423630329","full_name":"FelixHerrmann/swift-package-list","owner":"FelixHerrmann","description":"A command-line tool to get all used SPM-dependencies of an Xcode project or workspace.","archived":false,"fork":false,"pushed_at":"2024-03-18T16:53:27.000Z","size":416,"stargazers_count":103,"open_issues_count":3,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T11:14:43.020Z","etag":null,"topics":["acknowledgements","json","license","macos","objective-c","pdf","plist","plugin","settings-bundle","shell","swift","swift-package-manager","tuist","xcode"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FelixHerrmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-01T22:09:23.000Z","updated_at":"2024-05-28T00:03:36.979Z","dependencies_parsed_at":"2024-01-04T03:23:21.135Z","dependency_job_id":"ade2422b-d150-4b6e-839b-537387dbbfc4","html_url":"https://github.com/FelixHerrmann/swift-package-list","commit_stats":{"total_commits":160,"total_committers":2,"mean_commits":80.0,"dds":0.125,"last_synced_commit":"8b8c3fa7dcf9dc9f4a9baf045201cfc9653cfa34"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FelixHerrmann%2Fswift-package-list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FelixHerrmann%2Fswift-package-list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FelixHerrmann%2Fswift-package-list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FelixHerrmann%2Fswift-package-list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FelixHerrmann","download_url":"https://codeload.github.com/FelixHerrmann/swift-package-list/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246088437,"owners_count":20721685,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acknowledgements","json","license","macos","objective-c","pdf","plist","plugin","settings-bundle","shell","swift","swift-package-manager","tuist","xcode"],"created_at":"2024-07-31T19:02:00.683Z","updated_at":"2025-03-28T19:31:08.269Z","avatar_url":"https://github.com/FelixHerrmann.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# SwiftPackageList\n\n[![Xcode Build](https://github.com/FelixHerrmann/swift-package-list/actions/workflows/xcodebuild.yml/badge.svg)](https://github.com/FelixHerrmann/swift-package-list/actions/workflows/xcodebuild.yml)\n[![SwiftLint](https://github.com/FelixHerrmann/swift-package-list/actions/workflows/swiftlint.yml/badge.svg)](https://github.com/FelixHerrmann/swift-package-list/actions/workflows/swiftlint.yml)\n\nA command-line tool to get all used Swift Package dependencies.\n\nThe output includes all the `Package.resolved` informations and the license from the checkouts.\nYou can also generate a JSON, PLIST, Settings.bundle or PDF file.\n\nAdditionally there is a Swift Package to read the generated package-list file from the application's bundle or to use pre-build UI for SwiftUI and UIKit.\n\n\n## Command-Line Tool\n\n### Installation\n\n#### Using [Homebrew](https://brew.sh)\n\n```shell\nbrew tap FelixHerrmann/tap\nbrew install swift-package-list\n```\n\n#### Using [Mint](https://github.com/yonaskolb/mint):\n\n```shell\nmint install FelixHerrmann/swift-package-list\n```\n\n#### Installing from source:\n\nClone or download this repository and run `make install`, `make update` or `make uninstall`.\n\n### Usage\n\nOpen the terminal and run `swift-package-list \u003cproject-path\u003e` with the path to the project file you want to generate the list from.\nCurrently supported are:\n- `*.xcodeproj` for Xcode projects\n- `*.xcworkspace` for Xcode workspaces\n- `Package.swift` for Swift packages\n- `Project.swift` for Tuist projects\n- `Dependencies.swift` for Tuist projects with [external dependencies](https://docs.old.tuist.io/guides/third-party-dependencies)\n\nIn addition to that you can specify the following options:\n\n| Option                                                        | Description                                                                                                                     |\n| ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |\n| --custom-derived-data-path \\\u003ccustom-derived-data-path\\\u003e       | A custom path to your DerivedData-folder.                                                                                       |\n| --custom-source-packages-path \\\u003ccustom-source-packages-path\\\u003e | A custom path to the SourcePackages-folder.                                                                                     |\n| --custom-packages-file-path \\\u003ccustom-packages-file-path\\\u003e     | A path to a file containing custom packages in the same format as the JSON-output. (This option may be repeated multiple times) |\n| --output-type \\\u003coutput-type\\\u003e                                 | The type of output for the package-list. (values: stdout, json, plist, settings-bundle, pdf; default: stdout)                   |\n| --output-path \\\u003coutput-path\\\u003e                                 | The path where the package-list file will be stored. (Not required for stdout output-type)                                      |\n| --custom-file-name \\\u003ccustom-file-name\\\u003e                       | A custom filename to be used instead of the default ones.                                                                       |\n| --requires-license                                            | Will skip the packages without a license-file.                                                                                  |\n| --ignore-package \\\u003cpackage-identity\\\u003e                         | Will skip a package with the specified identity. (This option may be repeated multiple times)                                   |\n| --version                                                     | Show the version.                                                                                                               |\n| -h, --help                                                    | Show help information.                                                                                                          |\n\n### Build Tool Plugin\n\nThe easiest way to add this tool to your project is using the provided build-tool plugin, available for both Xcode projects and Swift packages.\n\nFor Xcode projects simply add it under the `Run Build Tool Plug-ins` section in the Target's Build Phases tab after you have added this package to the project's Package Dependencies; for Swift packages configure it in the `Package.swift` manifest, as described [here](https://github.com/apple/swift-package-manager/blob/main/Documentation/Plugins.md#using-a-package-plugin).\n\nBy default this will use the JSON output with `--requires-license` but you can create a `swift-package-list-config.json` in your project's root to configure that behavior, both project and target specific (target configs have precedence over the project one). Everything in the configuration is optional and has the following format:\n```json\n{\n    \"projectPath\" : \"Project.xcworkspace\",\n    \"project\" : {\n        \"outputType\" : \"plist\",\n        \"requiresLicense\" : false\n    },\n    \"targets\" : {\n        \"Target 1\" : {\n            \"outputType\" : \"settings-bundle\",\n            \"requiresLicense\" : true\n        },\n        \"Target 2\" : {\n            \"outputType\" : \"json\",\n            \"requiresLicense\" : true,\n            \"ignorePackages\" : [\n                \"swift-package-list\",\n                \"swift-argument-parser\",\n            ],\n            \"customPackagesFilePaths\" : [\n                \"custom-packages.json\",\n            ]\n        }\n    }\n}\n```\n\nOnce added and configured the file(s) will get generated during every build process and are available in the App's bundle.\nYou can then open them manually or use the various options in the included [Swift Package](#swift-package).\n\n\u003e [!NOTE]\n\u003e When using Xcode Cloud add `defaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation -bool YES`\n\u003e to `ci_post_clone.sh` which disables the plugin validation.\n\n### Run Script Phase\n\nYou can easily set up a Run Script Phase in your target of your Xcode project to keep the package-list file up to date automatically:\n\n1. open the corresponding target and click on the plus under the *Build Phases* section\n2. select *New Run Script Phase* and add the following script into the code box:\n```shell\nif command -v swift-package-list \u0026\u003e /dev/null; then\n    OUTPUT_PATH=$SOURCE_ROOT/$TARGETNAME\n    swift-package-list \"$PROJECT_FILE_PATH\" --output-type json --output-path \"$OUTPUT_PATH\" --requires-license\nelse\n    echo \"warning: swift-package-list not installed\"\nfi\n```\n3. move the Phase above the `Copy Bundle Resources`-phase\n4. optionally you can rename the Phase by double-clicking on the title\n5. build your project (\u003ckbd\u003ecmd\u003c/kbd\u003e + \u003ckbd\u003eb\u003c/kbd\u003e)\n6. right-click on the targets-folder in the sidebar and select *Add Files to \"\\\u003cproject-name\\\u003e\"*\n7. select `package-list.json` in the Finder-window\n\nThe package-list file will be updated now on every build and can be opened from the bundle in your app.\nYou can do that manually or use the [Swift Package](#swift-package) for that.\n\n#### Xcode Workspace (CocoaPods)\n\nIf you have an Xcode workspace instead of a standard Xcode project everything works exactly the same,\nyou just need a slightly modified script for the Run Script Phase:\n```shell\nif command -v swift-package-list \u0026\u003e /dev/null; then\n    OUTPUT_PATH=$SOURCE_ROOT/$TARGETNAME\n    WORKSPACE_FILE_PATH=${PROJECT_FILE_PATH%.xcodeproj}.xcworkspace\n    swift-package-list \"$WORKSPACE_FILE_PATH\" --output-type json --output-path \"$OUTPUT_PATH\" --requires-license\nelse\n    echo \"warning: swift-package-list not installed\"\nfi\n```\n\n#### Homebrew Troubleshooting on Apple Silicon\n\nIf you used Homebrew to install the Command-Line Tool on an Apple Silicon Mac, Xcode will not recognize the swift-package-list command.\nThis is because Homebrew uses it's own /bin directory and Xcode's PATH environment variable is not aware of that.\nThere are 2 easy ways to fix this issue:\n\n- add `export PATH=\"$PATH:/opt/homebrew/bin\"` as the first line to your build script\n- execute `ln -s /opt/homebrew/bin/swift-package-list /usr/local/bin/swift-package-list` in your Terminal\n\n#### Mint Troubleshooting\n\nIf you used Mint to install the Command-Line Tool, Xcode will not recognize the swift-package-list command.\nThis is because Mint uses it's own /bin directory and Xcode's PATH environment variable is not aware of that.\nThere are 2 easy ways to fix this issue:\n\n- add `export PATH=\"$PATH:$HOME/.mint/bin/\"` as the first line to your build script\n- execute `ln -s $HOME/.mint/bin/swift-package-list /usr/local/bin/swift-package-list` in your Terminal\n\n### Settings Bundle\n\nYou can also generate a `Settings.bundle` file to show the acknowledgements in the Settings app. This works slightly different\nthan the other file types, because a Settings Bundle is a collection of several files and might already exist in your app. \nJust specify `--output-type settings-bundle` on the command execution.\n\n**Important:** The `Root.plist` and `Root.strings` files will (unlike the other files) only be created if they not already exists,\notherwise it would remove existing configurations. Make sure you set up the `Acknowledgements.plist` correctly as a Child Pane as shown below:\n\n```xml\n\u003cdict\u003e\n    \u003ckey\u003eType\u003c/key\u003e\n    \u003cstring\u003ePSChildPaneSpecifier\u003c/string\u003e\n    \u003ckey\u003eTitle\u003c/key\u003e\n    \u003cstring\u003eAcknowledgements\u003c/string\u003e\n    \u003ckey\u003eFile\u003c/key\u003e\n    \u003cstring\u003eAcknowledgements\u003c/string\u003e\n\u003c/dict\u003e\n```\n\nFor more information on how to set up and use a Settings Bundle, take a look at Apple's [documentation](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/UserDefaults/Preferences/Preferences.html).\n\n### PDF\n\nOn macOS it is more common to show a `Acknowledgments.pdf` file. Therefore you have the option to generate a PDF with all licenses.\nJust specify `--output-type pdf` on the command execution.\n\nIt uses the project's file name (without extension) as the product name and, if present, the organization-name from the project file.\nYou can set that in your project's file inspector as shown [here](https://stackoverflow.com/a/38395030/11342085).\n\nOnce created and added to the project, it can be easily accessed from the application's bundle like the following:\n```swift\nimport SwiftPackageList\n\nlet url = Bundle.main.acknowledgementsURL\n```\nYou can then use [QuickLook](https://developer.apple.com/documentation/quicklook), [NSWorkspace.open(\\_:)](https://developer.apple.com/documentation/appkit/nsworkspace/1533463-open) or any other method to display the PDF.\n\n### Custom Packages\n\nTo provide custom packages or other items with licenses, you can use the `--custom-packages-file-path` option with a JSON file in the following format:\n\n```json\n[\n    {\n        \"branch\" : null,\n        \"identity\" : \"custom-package-example\",\n        \"kind\" : \"custom\",\n        \"license\" : null,\n        \"location\" : \"\",\n        \"name\" : \"CustomPackageExample\",\n        \"revision\" : null,\n        \"version\" : null\n    }\n]\n```\n\nAll optional fields have null values in this example and can be left out, the other ones are required.\n\n\n## Swift Package\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FFelixHerrmann%2Fswift-package-list%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/FelixHerrmann/swift-package-list)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FFelixHerrmann%2Fswift-package-list%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/FelixHerrmann/swift-package-list)\n\nLoad the generated package-list file from the bundle or use some pre-build UI components.\n\n### Requirements\n\n- macOS 10.15\n- iOS 13.0\n- tvOS 13.0\n- watchOS 6.0\n- visionOS 1.0\n\n### Usage\n\nAdd the package to your project as shown [here](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app).\n\nIt contains 2 libraries; `SwiftPackageList` for loading the Data and `SwiftPackageListUI` to get an iOS Settings-like user interface.\n\n#### SwiftPackageList\n\n```swift\nimport SwiftPackageList\n\nlet packageProvider = JSONPackageProvider()\ndo {\n    let packages = try packageProvider.packages()\n    // use packages\n} catch {\n    print(error)\n}\n```\n\n#### SwiftPackageListUI\n\n```swift\nimport SwiftPackageListUI\n\nlet acknowledgmentsViewController = SPLAcknowledgmentsTableViewController()\nacknowledgmentsViewController.canOpenRepositoryLink = true\nnavigationController.pushViewController(acknowledgmentsViewController, animated: true)\n```\n\n```swift\nimport SwiftPackageListUI\n\nvar body: some View {\n    NavigationStack {\n        AcknowledgmentsList()\n    }\n}\n```\n\n\n## Localization\n\nThe Settings Bundle and the UI-components are currently localized in the following languages:\n\n| Name                 | Code    |\n| -------------------- | ------- |\n| Arabic               | ar      |\n| Chinese, Simplified  | zh-Hans |\n| Chinese, Traditional | zh-Hant |\n| English              | en      |\n| French               | fr      |\n| German               | de      |\n| Hindi                | hi      |\n| Italian              | it      |\n| Japanese             | ja      |\n| Polish               | pl      |\n| Portuguese           | pt      |\n| Russian              | ru      |\n| Spanish              | es      |\n| Turkish              | tr      |\n| Ukrainian            | uk      |\n\n\u003e If a language has mistakes or is missing, feel free to create an issue or open a pull request.\n\n\n## Known limitations\n\n- SwiftPackageList won't include license files from packages that are located in a registry like Artifactory.\n\n\n## License\n\nSwiftPackageList is available under the MIT license. See the [LICENSE](https://github.com/FelixHerrmann/swift-package-list/blob/master/LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFelixHerrmann%2Fswift-package-list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFelixHerrmann%2Fswift-package-list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFelixHerrmann%2Fswift-package-list/lists"}