|
1 | 1 | # Package Collection
|
2 | 2 |
|
3 |
| -Package collections are short, curated lists of packages and associated metadata that can be imported |
4 |
| -by SwiftPM to make package discovery easier. Educators and community influencers can publish |
5 |
| -package collections to go along with course materials or blog posts, removing the friction of using |
6 |
| -packages for the first time and the cognitive overload of deciding which packages are useful for |
7 |
| -a particular task. Enterprises may use collections to narrow the decision space for their internal |
8 |
| -engineering teams, focusing them on a trusted set of vetted packages. |
9 |
| - |
10 |
| -## Creating a Package Collection |
11 |
| - |
12 |
| -A package collection is a JSON document that contains a list of packages and metadata per package. |
13 |
| - |
14 |
| -To begin, define the top-level metadata about the collection: |
15 |
| - |
16 |
| -* `name`: The name of the package collection, for display purposes only. |
17 |
| -* `overview`: A description of the package collection. **Optional.** |
18 |
| -* `keywords`: An array of keywords that the collection is associated with. **Optional.** |
19 |
| -* `formatVersion`: The version of the format to which the collection conforms. Currently, `1.0` is the only allowed value. |
20 |
| -* `revision`: The revision number of this package collection. **Optional.** |
21 |
| -* `generatedAt`: The ISO 8601-formatted datetime string when the package collection was generated. |
22 |
| -* `generatedBy`: The author of this package collection. **Optional.** |
23 |
| - * `name`: The author name. |
24 |
| -* `packages`: An array of package objects. |
25 |
| - |
26 |
| -#### Add packages to the collection |
27 |
| - |
28 |
| -Each item in the `packages` array is a package object with the following properties: |
29 |
| - |
30 |
| -* `url`: The URL of the package. Currently only Git repository URLs are supported. |
31 |
| -* `summary`: A description of the package. **Optional.** |
32 |
| -* `keywords`: An array of keywords that the package is associated with. **Optional.** |
33 |
| -* `readmeURL`: The URL of the package's README. **Optional.** |
34 |
| -* `license`: The package's *current* license information. **Optional.** |
35 |
| - * `url`: The URL of the license file. |
36 |
| - * `name`: License name. [SPDX identifier](https://spdx.org/licenses/) (e.g., `Apache-2.0`, `MIT`, etc.) preferred. Omit if unknown. **Optional.** |
37 |
| -* `versions`: An array of version objects representing the most recent and/or relevant releases of the package. |
38 |
| - |
39 |
| -#### Add versions to a package |
40 |
| - |
41 |
| -A version object has metadata extracted from `Package.swift` and optionally additional metadata from other sources: |
42 |
| - |
43 |
| -* `version`: The semantic version string. |
44 |
| -* `packageName`: The name of the package. |
45 |
| -* `targets`: An array of the package version's targets. |
46 |
| - * `name`: The target name. |
47 |
| - * `moduleName`: The module name if this target can be imported as a module. **Optional.** |
48 |
| -* `products`: An array of the package version's products. |
49 |
| - * `name`: The product name. |
50 |
| - * `type`: The product type. This must have the same JSON representation as SwiftPM's `PackageModel.ProductType`. |
51 |
| - * `target`: An array of the product’s targets. |
52 |
| - |
53 |
| -```json |
54 |
| -{ |
55 |
| - "name": "MyProduct", |
56 |
| - "type": { |
57 |
| - "library": ["automatic"] |
58 |
| - }, |
59 |
| - "targets": ["MyTarget"] |
60 |
| -} |
61 |
| -``` |
62 |
| - |
63 |
| -* `toolsVersion`: The tools (semantic) version specified in `Package.swift`. |
64 |
| -* `minimumPlatformVersions`: An array of the package version’s supported platforms specified in `Package.swift`. **Optional.** |
65 |
| - |
66 |
| -```json |
67 |
| -{ |
68 |
| - "name": "macOS", |
69 |
| - "version": "10.15" |
70 |
| -} |
71 |
| -``` |
72 |
| - |
73 |
| -* `verifiedCompatibility`: An array of compatible platforms and Swift versions that has been tested and verified for. Valid platform names include `macOS`, `iOS`, `tvOS`, `watchOS`, `Linux`, `Android`, and `Windows`. Swift version should be semantic version string and as specific as possible. **Optional.** |
74 |
| - |
75 |
| -```json |
76 |
| -{ |
77 |
| - "platform": { |
78 |
| - "name": "macOS" |
79 |
| - }, |
80 |
| - "swiftVersion": "5.3.2" |
81 |
| -} |
82 |
| -``` |
83 |
| - |
84 |
| -* `license`: The package version's license. **Optional.** |
85 |
| - * `url`: The URL of the license file. |
86 |
| - * `name`: License name. [SPDX identifier](https://spdx.org/licenses/) (e.g., `Apache-2.0`, `MIT`, etc.) preferred. Omit if unknown. **Optional.** |
87 |
| - |
88 |
| -## Example |
89 |
| - |
90 |
| -```json |
91 |
| -{ |
92 |
| - "name": "Sample Package Collection", |
93 |
| - "overview": "This is a sample package collection listing made-up packages.", |
94 |
| - "keywords": ["sample package collection"], |
95 |
| - "formatVersion": "1.0", |
96 |
| - "revision": 3, |
97 |
| - "generatedAt": "2020-10-22T06:03:52Z", |
98 |
| - "packages": [ |
99 |
| - { |
100 |
| - "url": "https://www.example.com/repos/RepoOne.git", |
101 |
| - "summary": "Package One", |
102 |
| - "readmeURL": "https://www.example.com/repos/RepoOne/README", |
103 |
| - "license": { |
104 |
| - "name": "Apache-2.0", |
105 |
| - "url": "https://www.example.com/repos/RepoOne/LICENSE" |
106 |
| - }, |
107 |
| - "versions": [ |
108 |
| - { |
109 |
| - "version": "0.1.0", |
110 |
| - "packageName": "PackageOne", |
111 |
| - "targets": [ |
112 |
| - { |
113 |
| - "name": "Foo", |
114 |
| - "moduleName": "Foo" |
115 |
| - } |
116 |
| - ], |
117 |
| - "products": [ |
118 |
| - { |
119 |
| - "name": "Foo", |
120 |
| - "type": { |
121 |
| - "library": ["automatic"] |
122 |
| - }, |
123 |
| - "targets": ["Foo"] |
124 |
| - } |
125 |
| - ], |
126 |
| - "toolsVersion": "5.1", |
127 |
| - "verifiedCompatibility": [ |
128 |
| - { |
129 |
| - "platform": { "name": "macOS" }, |
130 |
| - "swiftVersion": "5.1" |
131 |
| - }, |
132 |
| - { |
133 |
| - "platform": { "name": "iOS" }, |
134 |
| - "swiftVersion": "5.1" |
135 |
| - }, |
136 |
| - { |
137 |
| - "platform": { "name": "Linux" }, |
138 |
| - "swiftVersion": "5.1" |
139 |
| - } |
140 |
| - ], |
141 |
| - "license": { |
142 |
| - "name": "Apache-2.0", |
143 |
| - "url": "https://www.example.com/repos/RepoOne/LICENSE" |
144 |
| - } |
145 |
| - } |
146 |
| - ] |
147 |
| - }, |
148 |
| - { |
149 |
| - "url": "https://www.example.com/repos/RepoTwo.git", |
150 |
| - "summary": "Package Two", |
151 |
| - "readmeURL": "https://www.example.com/repos/RepoTwo/README", |
152 |
| - "versions": [ |
153 |
| - { |
154 |
| - "version": "2.1.0", |
155 |
| - "packageName": "PackageTwo", |
156 |
| - "targets": [ |
157 |
| - { |
158 |
| - "name": "Bar", |
159 |
| - "moduleName": "Bar" |
160 |
| - } |
161 |
| - ], |
162 |
| - "products": [ |
163 |
| - { |
164 |
| - "name": "Bar", |
165 |
| - "type": { |
166 |
| - "library": ["automatic"] |
167 |
| - }, |
168 |
| - "targets": ["Bar"] |
169 |
| - } |
170 |
| - ], |
171 |
| - "toolsVersion": "5.2" |
172 |
| - }, |
173 |
| - { |
174 |
| - "version": "1.8.3", |
175 |
| - "packageName": "PackageTwo", |
176 |
| - "targets": [ |
177 |
| - { |
178 |
| - "name": "Bar", |
179 |
| - "moduleName": "Bar" |
180 |
| - } |
181 |
| - ], |
182 |
| - "products": [ |
183 |
| - { |
184 |
| - "name": "Bar", |
185 |
| - "type": { |
186 |
| - "library": ["automatic"] |
187 |
| - }, |
188 |
| - "targets": ["Bar"] |
189 |
| - } |
190 |
| - ], |
191 |
| - "toolsVersion": "5.0" |
192 |
| - } |
193 |
| - ] |
194 |
| - } |
195 |
| - ] |
196 |
| -} |
197 |
| -``` |
| 3 | +This file has been relocated to [PackageCollectionsModel/Formats/v1](https://github.com/apple/swift-package-manager/tree/main/Sources/PackageCollectionsModel/Formats/v1.md) in SwiftPM. |
0 commit comments