Package Collections (SE-0291) are short, curated lists of packages and associated metadata that can be imported by SwiftPM to make package discovery easier. This is a draft of the format that all package collections must adhere to.
Creating a package collection
A package collection is a JSON document that contains a list of packages and metadata per package.
To begin, define the top-level metadata about the collection:
-
name
: The name of the package collection, for display purposes only. -
overview
: A description of the package collection. Optional. -
keywords
: An array of keywords that the package collection is associated with. Optional. -
formatVersion
: The version of the format to which the package collection conforms. Currently,1.0
is the only allowed value. -
revision
: The revision number of this package collection. Optional. -
generatedAt
: The ISO 8601-formatted date-time string when the package collection was generated. -
generatedBy
: The author of this package collection. Optional.
{
"name": "Jane Doe"
}
-
packages
: An array of package objects.
Add packages to the collection
Each item in the packages
array is a package object with the following properties:
-
url
: The URL of the package. Currently only Git repository URLs are supported. -
summary
: A description of the package. Optional. -
keywords
: An array of keywords that the package is associated with. Optional. -
readmeURL
: The URL of the package's README. Optional. -
versions
: An array of version objects representing the most recent and/or relevant releases of the package.
Add versions to a package
A version object has metadata extracted from Package.swift
and optionally additional metadata from other sources:
-
version
: The semantic version string. -
packageName
: The name of the package. -
targets
: An array of the package version's targets.-
name
: The target name. -
moduleName
: The module name if this target can be imported as a module. Optional.
-
-
products
: An array of the package version's products.-
name
: The product name. -
type
: The product type. This must have the same JSON representation as SwiftPM'sPackageModel.ProductType
. -
target
: An array of the product’s targets.
-
{
"name": "MyProduct",
"type": {
"library": ["automatic"]
},
"targets": ["MyTarget"]
}
-
toolsVersion
: The tools (semantic) version specified inPackage.swift
. -
minimumPlatformVersions
: An array of the package version’s supported platforms specified inPackage.swift
. Optional.
{
"name": "macOS",
"version": "10.15"
}
-
verifiedPlatforms
: An array of platforms in which the package version has been tested and verified. Valid platform names includemacOS
,iOS
,tvOS
,watchOS
,Linux
,Android
, andWindows
. This is different fromplatforms
inPackage.swift
. Optional.
{
"name": "macOS"
}
-
verifiedSwiftVersions
: An array of Swift versions that the package version has been tested and verified for. Values must be semantic version strings. This is different fromswiftLanguageVersions
inPackage.swift
. Optional. -
license
: The package version's license. Optional.-
name
: License name. SPDX identifier ( e.g. ,Apache-2.0
,MIT
, etc.) preferred. -
url
: The URL of the license file.
-
Other requirements
- The number of versions included for each package will be limited--the current proposal is at most two major versions and up to three minor versions per major version.
Sample package collection
{
"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",
"versions": [
{
"version": "0.1.0",
"packageName": "PackageOne",
"targets": [
{
"name": "Foo",
"moduleName": "Foo"
}
],
"products": [
{
"name": "Foo",
"type": {
"library": ["automatic"]
},
"targets": ["Foo"]
}
],
"toolsVersion": "5.1",
"verifiedPlatforms": [
{ "name": "macOS" },
{ "name": "iOS" },
{ "name": "Linux" }
],
"verifiedSwiftVersions": ["5.1"],
"license": {
"name": "Apache-2.0",
"url": "https://www.example.com/repos/RepoOne/LICENSE"
}
}
]
},
{
"url": "https://www.example.com/repos/RepoTwo.git",
"summary": "Package Two",
"readmeURL": "https://www.example.com/repos/RepoTwo/README",
"versions": [
{
"version": "2.1.0",
"packageName": "PackageTwo",
"targets": [
{
"name": "Bar",
"moduleName": "Bar"
}
],
"products": [
{
"name": "Bar",
"type": {
"library": ["automatic"]
},
"targets": ["Bar"]
}
],
"toolsVersion": "5.2"
},
{
"version": "1.8.3",
"packageName": "PackageTwo",
"targets": [
{
"name": "Bar",
"moduleName": "Bar"
}
],
"products": [
{
"name": "Bar",
"type": {
"library": ["automatic"]
},
"targets": ["Bar"]
}
],
"toolsVersion": "5.0"
}
]
}
]
}