### Install Executable Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/swift-package-registry/CMakeLists.txt Installs the 'swift-package-registry' executable to the 'bin' directory at runtime. ```cmake install(TARGETS swift-package-registry RUNTIME DESTINATION bin) ``` -------------------------------- ### Run SwiftPM Example Package Source: https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/libSwiftPM.md Clone the SwiftPM repository and navigate to the package-info example directory to run the demonstration package. ```sh $ git clone https://github.com/swiftlang/swift-package-manager $ cd swift-package-manager/Examples/package-info $ swift run ``` -------------------------------- ### Configure and Install Swift Interface Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/Runtimes/PackagePlugin/CMakeLists.txt Sets the installation directory for the Swift module interface and then installs it. This ensures the plugin API is correctly exposed. ```cmake set(SwiftPMRuntime_INSTALL_SWIFTMODULEDIR ${CMAKE_INSTALL_LIBDIR}/swift/pm/PluginAPI) emit_swift_interface(PackagePlugin) install_swift_interface(PackagePlugin) ``` -------------------------------- ### Install Executable Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/swift-experimental-sdk/CMakeLists.txt Installs the 'swift-experimental-sdk' executable to the 'bin' directory at runtime. This makes the compiled binary available in the system's PATH. ```cmake install(TARGETS swift-experimental-sdk RUNTIME DESTINATION bin) ``` -------------------------------- ### Install Bash Completions Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/UsingShellCompletion.md Use these commands to install Bash completions to `~/.swift-package-complete.bash` and load them using your `~/.bash_profile` file. ```bash swift package completion-tool generate-bash-script > ~/.swift-package-complete.bash echo -e "source ~/.swift-package-complete.bash\n" >> ~/.bash_profile source ~/.swift-package-complete.bash ``` -------------------------------- ### Install Swift Executable Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/swift-test/CMakeLists.txt Installs the 'swift-test' executable to the 'bin' directory at runtime. This ensures the executable is available after installation. ```cmake install(TARGETS swift-test RUNTIME DESTINATION bin) ``` -------------------------------- ### Install CompilerPluginSupport Library and Interface Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/Runtimes/CompilerPluginSupport/CMakeLists.txt Installs the CompilerPluginSupport library to the specified directory and emits and installs its Swift interface. ```cmake install(TARGETS CompilerPluginSupport DESTINATION ${CMAKE_INSTALL_LIBDIR}/swift/pm/ManifestAPI) set(SwiftPMRuntime_INSTALL_SWIFTMODULEDIR ${CMAKE_INSTALL_LIBDIR}/swift/pm/ManifestAPI) emit_swift_interface(CompilerPluginSupport) install_swift_interface(CompilerPluginSupport) ``` -------------------------------- ### Install Swift SDK Executable Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/swift-sdk/CMakeLists.txt Configures the installation of the Swift SDK executable. This specifies that the built runtime artifact should be placed in the 'bin' directory of the installation prefix. ```cmake install(TARGETS swift-sdk RUNTIME DESTINATION bin) ``` -------------------------------- ### Registry Configuration Example Source: https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/PackageRegistryUsage.md JSON configurations for user-level and local registry mappings, illustrating precedence rules. ```json // User-level configuration (~/.swiftpm/configuration/registries.json) { "registries": { "[default]": { "url": "https://global.example.com" }, "foo": { "url": "https://global.example.com" }, }, "version": 1 } // Local configuration (.swiftpm/configuration/registries.json) { "registries": { "foo": { "url": "https://local.example.com" } }, "version": 1 } ``` -------------------------------- ### Example GET Request with Accept Header for API Versioning Source: https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/Registry.md Clients should specify the desired API version using the 'Accept' header. This example requests version 1 of the registry API. ```http GET /mona/LinkedList/list HTTP/1.1 Host: packages.example.com Accept: application/vnd.swift.registry.v1+json ``` -------------------------------- ### Clone Example Package Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/GettingStarted.md Clone the 'Dealer' example package locally to explore its structure and dependencies. ```bash git clone https://github.com/swiftlang/example-package-dealer.git cd example-package-dealer ``` -------------------------------- ### Install and Use Swiftly for Toolchain Management Source: https://github.com/swiftlang/swift-package-manager/blob/main/CONTRIBUTING.md Use the 'swiftly' tool to install the recommended Swift toolchain and then build and test the Swift Package Manager project. This simplifies toolchain management. ```bash swiftly install swift build swift test ``` -------------------------------- ### Package Manifest Example Source: https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/PackageRegistryUsage.md A basic Package.swift file demonstrating the structure and including a placeholder for a CMS signature. ```swift // swift-tools-version: 5.7 import PackageDescription let package = Package( name: "library", products: [ .library(name: "library", targets: ["library"]) ], targets: [ .target(name: "library")] ) // signature: cms-1.0.0;l1TdTeIuGdNsO1FQ0ptD64F5nSSOsQ5WzhM6/7KsHRuLHfTsggnyIWr0DxMcBj5F40zfplwntXAgS0ynlqvlFw== ``` -------------------------------- ### Install swift-run Executable Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/swift-run/CMakeLists.txt Specifies that the swift-run executable should be installed to the 'bin' directory at runtime. ```cmake install(TARGETS swift-run RUNTIME DESTINATION bin) ``` -------------------------------- ### Start Docker Container for Swift Nightly Toolchain Source: https://github.com/swiftlang/swift-package-manager/blob/main/Utilities/README.md Launches a Docker container with the specified Swift nightly toolchain on Windows Server Core. Ensure Docker is installed and configured for Windows containers. ```powershell docker run --pull always --rm --interactive --tty swiftlang/swift:nightly-6.3-windowsservercore-1809 powershell.exe ``` -------------------------------- ### Install Swift Build Executable Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/swift-build/CMakeLists.txt Specifies the installation destination for the swift-build executable. ```cmake install(TARGETS swift-build DESTINATION bin) ``` -------------------------------- ### Install Swift Package Executable Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/swift-package/CMakeLists.txt Specifies the installation rules for the swift-package executable, placing it in the bin directory. ```cmake install(TARGETS swift-package RUNTIME DESTINATION bin) ``` -------------------------------- ### Show Version or Help Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/PackageRegistry/PackageRegistryLogin.md Display the version with `--version` or get help with `--help`. ```bash package-registry login --version ``` ```bash package-registry login --help ``` -------------------------------- ### Install Zsh Completions Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/UsingShellCompletion.md Use these commands to install Zsh completions to `~/.zsh/_swift`. This will also add `~/.zsh` to your `$fpath` using your `~/.zshrc` file. ```zsh mkdir ~/.zsh swift package completion-tool generate-zsh-script > ~/.zsh/_swift echo -e "fpath=(~/.zsh $fpath)\n" >> ~/.zshrc compinit ``` -------------------------------- ### Package Version Verified Compatibility Example Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageCollectionsModel/Formats/v1.md Shows an example of the `verifiedCompatibility` field, which lists platforms and Swift versions that have verified compatibility with the package version. ```json { "platform": { "name": "macOS" }, "swiftVersion": "5.3.2" } ``` -------------------------------- ### Package Build and Test Output Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/GettingStarted.md Example output from building and running tests for a Swift package. This shows the build process and the results of the executed tests. ```bash Building for debugging... [6/6] Linking DeckOfPlayingCardsPackageTests Build complete! (0.44s) Test Suite 'All tests' started at 2025-10-09 13:16:44.052. Test Suite 'All tests' passed at 2025-10-09 13:16:44.052. Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.001) seconds ◇ Test run started. ↳ Testing Library Version: 1400 ↳ Target Platform: arm64e-apple-macos14.0 ◇ Suite DeckTests started. ◇ Test deal() started. ◇ Test countStandard52CardDeckHas52Cards() started. ◇ Test countEmptyDeckHasZeroCards() started. ◇ Test standard52CardDeck() started. ◇ Test countDealingDecreasesCountByOne() started. ✔ Test countDealingDecreasesCountByOne() passed after 0.001 seconds. ✔ Test deal() passed after 0.001 seconds. ✔ Test countStandard52CardDeckHas52Cards() passed after 0.001 seconds. ✔ Test countEmptyDeckHasZeroCards() passed after 0.001 seconds. ✔ Test standard52CardDeck() passed after 0.001 seconds. ✔ Suite DeckTests passed after 0.001 seconds. ✔ Test run with 5 tests in 1 suite passed after 0.001 seconds. ``` -------------------------------- ### Install Swift Package Collection Executable Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/swift-package-collection/CMakeLists.txt Specifies the installation rules for the swift-package-collection executable, placing it in the bin directory. ```cmake install(TARGETS swift-package-collection RUNTIME DESTINATION bin) ``` -------------------------------- ### Version and Help Flags Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/Package/PackageResolve.md Display the package manager version with `--version` or get help information with `--help`. ```bash package resolve --version ``` ```bash package resolve --help ``` -------------------------------- ### Run Package Executable (Initial) Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/GettingStarted.md Execute the command-line tool provided by the package using 'swift run'. This example shows the usage and an error due to missing arguments. ```bash [1/1] Planning build Building for debugging... [1/1] Write swift-version-2C315BDEC41BFF30.txt Build of product 'dealer' complete! (0.13s) Error: Missing expected argument ' ...' OVERVIEW: Shuffles a deck of playing cards and deals a number of cards. For each count argument, prints a line of tab-delimited cards to stdout, or if there aren't enough cards remaining, prints "Not enough cards" to stderr and exits with a nonzero status. USAGE: dealer ... ARGUMENTS: The number of cards to deal at a time. OPTIONS: -h, --help Show help information. ``` -------------------------------- ### Verify Swift Toolchain Installation (Linux) Source: https://github.com/swiftlang/swift-package-manager/blob/main/CONTRIBUTING.md Verify the installation of the Swift toolchain on Linux by checking the swift executable path and version. Ensure the PATH environment variable includes the toolchain's bin directory. ```bash $> export PATH=/path/to/swift-toolchain/usr/bin:"${PATH}" $> which swift /path/to/swift-toolchain/usr/bin/swift $> swift package --version Swift Package Manager - Swift 5.3.0 $> swift --version Apple Swift version 5.3 ``` -------------------------------- ### Sample Package Collection v1 Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageCollectionsModel/Formats/v1.md An example of a v1 package collection JSON file, demonstrating the structure for listing packages, their versions, and compatibility information. ```json { "name": "Sample Package Collection", "overview": "This is a sample package collection listing made-up packages.", "keywords": ["sample package collection"], "formatVersion": "1.0", "revision": 3, "generatedAt": "2020-10-22T06:03:52Z", "packages": [ { "url": "https://www.example.com/repos/RepoOne.git", "summary": "Package One", "readmeURL": "https://www.example.com/repos/RepoOne/README", "license": { "name": "Apache-2.0", "url": "https://www.example.com/repos/RepoOne/LICENSE" }, "versions": [ { "version": "0.1.0", "summary": "Fixed a few bugs", "manifests": { "5.1": { "toolsVersion": "5.1", "packageName": "PackageOne", "targets": [ { "name": "Foo", "moduleName": "Foo" } ], "products": [ { "name": "Foo", "type": { "library": ["automatic"] }, "targets": ["Foo"] } ] } }, "defaultToolsVersion": "5.1", "verifiedCompatibility": [ { "platform": { "name": "macOS" }, "swiftVersion": "5.1" }, { "platform": { "name": "iOS" }, "swiftVersion": "5.1" }, { "platform": { "name": "Linux" }, "swiftVersion": "5.1" } ], "license": { "name": "Apache-2.0", "url": "https://www.example.com/repos/RepoOne/LICENSE" }, "createdAt": "2020-10-21T09:25:36Z" } ] }, { "url": "https://www.example.com/repos/RepoTwo.git", "summary": "Package Two", "readmeURL": "https://www.example.com/repos/RepoTwo/README", "versions": [ { "version": "2.1.0", "manifests": { "5.2": { "toolsVersion": "5.2", "packageName": "PackageTwo", "targets": [ { "name": "Bar", "moduleName": "Bar" } ], "products": [ { "name": "Bar", "type": { "library": ["automatic"] }, "targets": ["Bar"] } ] } }, "defaultToolsVersion": "5.2" }, { "version": "1.8.3", "manifests": { "5.0": { "toolsVersion": "5.0", "packageName": "PackageTwo", "targets": [ { "name": "Bar", "moduleName": "Bar" } ], "products": [ { "name": "Bar", "type": { "library": ["automatic"] }, "targets": ["Bar"] } ] } }, "defaultToolsVersion": "5.0" } ] } ] } ``` -------------------------------- ### Preview Generated Documentation Source: https://github.com/swiftlang/swift-package-manager/blob/main/CONTRIBUTING.md Generates documentation using DocC and starts a local server to preview changes. Ensure the symbol graph is dumped first. ```bash xcrun docc preview Sources/PackageDescription/PackageDescription.docc --additional-symbol-graph-dir .build/*/symbolgraph/ ``` -------------------------------- ### Get Swift Package Manager Version Source: https://github.com/swiftlang/swift-package-manager/blob/main/README.md Verify your Swift Package Manager installation by checking its version. This command is useful after installation to confirm the tool is accessible and functioning. ```bash $ swift package --version Apple Swift Package Manager - ... ``` -------------------------------- ### Enable SwiftBuild Preview Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/ReleaseNotes/6.3.md Use the `--build-system swiftbuild` flag to enable the SwiftBuild preview for building, testing, or running executables. ```bash swift build --build-system swiftbuild ``` ```bash swift test --build-system swiftbuild ``` ```bash swift run --build-system swiftbuild MyExecutable ``` -------------------------------- ### Initialize a Library Package Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/CreatingSwiftPackage.md Use this command to create a new directory and initialize it as a Swift package focused on providing a library. The command sets up a standard directory structure for sources and tests. ```bash $ mkdir MyPackage $ cd MyPackage $ swift package init ``` -------------------------------- ### Show Build Subcommand Help Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/SwiftBuild.md Displays help information for the `swift build` subcommand and its available subcommands. Use this to understand the options and usage of build-related commands. ```bash build help [...] ``` -------------------------------- ### Set Build System Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/PackageRegistry/PackageRegistrySet.md Use `--build-system` to specify the build system to use. ```bash package-registry set --build-system= ``` -------------------------------- ### Install DriverSupport Target Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/DriverSupport/CMakeLists.txt Configures the installation destinations for the DriverSupport library artifacts. ```cmake install(TARGETS DriverSupport ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) ``` -------------------------------- ### Display Version or Help Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/PackageRegistry/PackageRegistrySet.md Use `--version` to display the command version or `--help` to show the help message. ```bash package-registry set --version ``` ```bash package-registry set --help ``` -------------------------------- ### Build and Test a Library Package Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/CreatingSwiftPackage.md After initializing a library package, you can immediately use the `swift build` command to compile your package and `swift test` to run its tests. ```bash $ swift build $ swift test ``` -------------------------------- ### Run SwiftPM Benchmarks Source: https://github.com/swiftlang/swift-package-manager/blob/main/Benchmarks/README.md Execute benchmarks in their default configuration. Ensure you are in the `Benchmarks` subdirectory. ```bash swift package benchmark ``` -------------------------------- ### Source Control Dependency Example Source: https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/PackageRegistryUsage.md An example of declaring a dependency using a source control URL in Package.swift. ```swift dependencies: [ .package(url: "https://github.com/mona/LinkedList", .upToNextMajor(from: "1.0.0")), ], ``` -------------------------------- ### Product Initialization Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageCollectionsModel/Documentation.docc/Curation/Product.md Initializes a new Product with a name, type, and associated targets. ```APIDOC ## `init(name:type:targets:)` ### Description Initializes a new `Product` instance. ### Parameters - **name** (`String`) - The name of the product. - **type** (`Product.ProductType`) - The type of the product. - **targets** (`[TargetReference]`) - An array of references to the targets that make up the product. ``` -------------------------------- ### Creating a Platform Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageCollectionsModel/Documentation.docc/Curation/Platform.md Initializes a new `Platform` instance with a given name. ```APIDOC ## init(name:) ### Description Creates a new `Platform` instance. ### Parameters #### Path Parameters - **name** (String) - Required - The name of the platform. ``` -------------------------------- ### Install PackageCollectionsCommand Target Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageCollectionsCommand/CMakeLists.txt Defines installation rules for the PackageCollectionsCommand target, specifying destinations for archives, libraries, and runtimes. ```cmake install(TARGETS PackageCollectionsCommand ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) ``` -------------------------------- ### Specify Build System Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/PackageRegistry/PackageRegistryLogin.md Use `--build-system` to specify the build system. Use `=` for debug info format. ```bash package-registry login --build-system= ``` ```bash package-registry login --= ``` -------------------------------- ### Install PackagePlugin Target Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/Runtimes/PackagePlugin/CMakeLists.txt Installs the PackagePlugin target to a specific destination directory within the Swift Package Manager's plugin API directory. ```cmake install(TARGETS PackagePlugin DESTINATION ${CMAKE_INSTALL_LIBDIR}/swift/pm/PluginAPI) ``` -------------------------------- ### Initialize a Command-Line Tool Package Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/CreatingSwiftPackage.md For creating a command-line executable that utilizes the `swift-argument-parser` for argument parsing, use `--type tool` when initializing the package. This also provides a functional 'Hello World' example. ```bash $ swift package init --type tool ``` -------------------------------- ### Verify Swift Toolchain Installation (macOS) Source: https://github.com/swiftlang/swift-package-manager/blob/main/CONTRIBUTING.md Verify the installation of the Swift toolchain on macOS by checking the swift executable path and version. Ensure the TOOLCHAINS environment variable is set to 'swift'. ```bash $> export TOOLCHAINS=swift $> xcrun --find swift /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swift $> swift package --version Swift Package Manager - Swift 5.3.0 $> swift --version Apple Swift version 5.3 ``` -------------------------------- ### GET Request to Lookup Package Identifiers by URL Source: https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/Registry.md Clients send a GET request to the /identifiers endpoint, providing the URL of the repository as a query parameter. The Accept header should be set to application/vnd.swift.registry.v1+json. ```http GET /identifiers?url=https://github.com/mona/LinkedList HTTP/1.1 Host: packages.example.com Accept: application/vnd.swift.registry.v1 ``` -------------------------------- ### List Available Swift SDKs Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/SDK/SDKList.md Use this command to list all available Swift SDKs on your system. It can be customized with various path and configuration options. ```bash sdk list [--package-path=] [--cache-path=] [--config-path=] [--security-path=] [--scratch-path=] [--swift-sdks-path=] [--toolset=...] [--pkg-config-path=...] [--version] [--help] ``` -------------------------------- ### Inspecting Packages Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/Runtimes/PackagePlugin/Documentation.docc/Curation/Package.md Access properties to get information about the package. ```APIDOC ## Package Properties ### Description Provides access to various attributes of a package. ### Properties - ``id``: Unique identifier for the package. - ``displayName``: The human-readable name of the package. - ``toolsVersion``: The version of the Swift tools used by the package. - ``directoryURL``: The URL to the package's directory. - ``origin``: Information about the package's origin (e.g., Git repository). - ``dependencies``: A list of the package's dependencies. - ``sourceModules``: The source modules defined within the package. - ``ID``: An alias for the package's unique identifier. - ``directory``: An alias for the package's directory URL. ``` -------------------------------- ### apt(_:) Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/Runtimes/PackageDescription/PackageDescription.docc/Curation/SystemPackageProvider.md Provides a hint for the apt package manager. ```APIDOC ## apt(_:) ### Description Provides a hint for the apt package manager. ### Method Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response None ``` -------------------------------- ### Example Registries Configuration Source: https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/PackageRegistryUsage.md Illustrates the structure of the `registries.json` file, showing an unscoped default registry. ```json { "registries" : { "[default]" : { "url": "https://packages.example.com" } }, "version" : 1 } ``` -------------------------------- ### Build System Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/Package/PackageResolve.md Specify the build system to use with `--build-system=`. ```bash package resolve --build-system=phony ``` -------------------------------- ### Creating a plugin Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/Runtimes/PackagePlugin/Documentation.docc/Curation/Plugin.md Initializes a new plugin instance. This is the entry point for creating a plugin. ```APIDOC ## init() ### Description Initializes a new plugin instance. ### Method init() ### Parameters None ``` -------------------------------- ### Initialize an Executable Package Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/CreatingSwiftPackage.md To create a Swift package structured for providing an executable, use the `--type executable` option with the `swift package init` command. This sets up a basic 'Hello World' executable. ```bash $ mkdir MyExecutable $ cd MyExecutable $ swift package init --type executable $ swift run ``` -------------------------------- ### Specify Swift SDKs Path Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/PackageRegistry/PackageRegistryLogin.md Use `--swift-sdks-path` to specify the directory containing installed Swift SDKs. ```bash package-registry login --swift-sdks-path= ``` -------------------------------- ### Specify Swift SDKs Path Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/PackageRegistry/PackageRegistrySet.md Use `--swift-sdks-path` to provide the path to the directory containing installed Swift SDKs. ```bash package-registry set --swift-sdks-path= ``` -------------------------------- ### Execute Built Tool Directly Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/GettingStarted.md Run the executable directly from the build directory, for example, '.build/debug/dealer 5', after the package has been built. ```bash .build/debug/dealer 5 ``` ```bash ♠︎ 6 ♡ 4 ♣︎ 4 ♡ A ♡ K ``` -------------------------------- ### Request Source Archive Source: https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/Registry.md Clients should send a GET request to the archive URI with the correct Accept header and .zip extension. ```http GET /mona/LinkedList/1.1.1.zip HTTP/1.1 Host: packages.example.com Accept: application/vnd.swift.registry.v1+zip ``` -------------------------------- ### Package Version Manifest Example Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageCollectionsModel/Formats/v1.md Illustrates the structure of the `manifests` field for a package version, showing details like tools version, package name, targets, products, and minimum platform versions. ```json { "5.2": { "toolsVersion": "5.2", "packageName": "MyPackage", "targets": [ { "name": "MyTarget", "moduleName": "MyTarget" } ], "products": [ { "name": "MyProduct", "type": { "library": ["automatic"] }, "targets": ["MyTarget"] } ], "minimumPlatformVersions": [ { "name": "macOS", "version": "10.15" } ] } } ``` -------------------------------- ### Package Manifest for swift-draw Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageManagerDocs/Documentation.docc/ModuleAliasing.md This is an example package manifest for a Swift package named 'swift-draw'. It defines libraries for 'Utils' and 'Logging' modules. ```json { name: "swift-draw", products: [ .library(name: "Utils", targets: ["Utils"]), .library(name: "Logging", targets: ["Logging"]), ], targets: [ .target(name: "Utils", dependencies: []), .target(name: "Logging", dependencies: []), ] } ``` -------------------------------- ### Poll for Asynchronous Publication Status Source: https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/Registry.md Client GET request to poll the status of an asynchronous publication. The Host and Accept headers are required. ```http GET /submissions/90D8CC77-A576-47AE-A531-D6402C4E33BC HTTP/1.1 Host: packages.example.com Accept: application/vnd.swift.registry.v1 ``` -------------------------------- ### Creating a Manifest Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageCollectionsModel/Documentation.docc/Curation/Collection_Package_Version_Manifest.md Initializes a new `Manifest` object with the specified details. ```APIDOC ## init(toolsVersion: packageName: targets: products: minimumPlatformVersions:) ### Description Creates a new `Manifest` object. ### Parameters - **toolsVersion** (`ToolsVersion`) - **packageName** (`String`) - **targets** (`[Target]`) - **products** (`[Product]`) - **minimumPlatformVersions** (`[PlatformVersion]`) ``` -------------------------------- ### Creating a Platform Version Source: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackageCollectionsModel/Documentation.docc/Curation/PlatformVersion.md Initializes a new `PlatformVersion` instance with a name and version string. ```APIDOC ## `init(name:version:)` ### Description Creates a new `PlatformVersion` with the specified name and version. ### Parameters - **name** (`String`) - The name of the platform (e.g., "macOS", "iOS"). - **version** (`String`) - The version string of the platform (e.g., "13.0", "16.0"). ``` -------------------------------- ### Request Package Releases Source: https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/Registry.md Send a GET request to the package URI with the appropriate Accept header to retrieve a list of available releases. ```http GET /mona/LinkedList HTTP/1.1 Host: packages.example.com Accept: application/vnd.swift.registry.v1+json ```