Skip to content

Commit 8fe1ddc

Browse files
authored
[Release Tooling] Initial xcprivacy file generation tooling (#12134)
1 parent e8cd98f commit 8fe1ddc

File tree

4 files changed

+113
-0
lines changed

4 files changed

+113
-0
lines changed

ReleaseTooling/Package.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ let package = Package(
2626
.executable(name: "zip-builder", targets: ["ZipBuilder"]),
2727
.executable(name: "podspecs-tester", targets: ["PodspecsTester"]),
2828
.executable(name: "manifest", targets: ["ManifestParser"]),
29+
.executable(name: "privacy-manifest-generator", targets: ["PrivacyManifestGenerator"]),
2930
],
3031
dependencies: [
3132
.package(url: "https://github.com/apple/swift-argument-parser", .exact("0.1.0")),
@@ -53,5 +54,12 @@ let package = Package(
5354
.target(
5455
name: "Utils"
5556
),
57+
.target(
58+
name: "PrivacyManifestGenerator",
59+
dependencies: ["ArgumentParser", "PrivacyKit"]
60+
),
61+
.target(
62+
name: "PrivacyKit"
63+
),
5664
]
5765
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import Foundation
16+
17+
/// Represents a Privacy Manifest as described in
18+
/// https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
19+
public struct PrivacyManifest {
20+
public init() {}
21+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import Foundation
16+
import PrivacyKit
17+
18+
/// Provides an API to walk the client through the creation of a Privacy
19+
/// Manifest via a series of questions.
20+
final class PrivacyManifestWizard {
21+
private let xcframework: URL
22+
23+
init(xcframework: URL) {
24+
self.xcframework = xcframework
25+
}
26+
27+
func nextQuestion() -> String? {
28+
// TODO(ncooke3): Implement.
29+
nil
30+
}
31+
32+
func processAnswer(_ answer: String) throws {
33+
// TODO(ncooke3): Implement.
34+
}
35+
36+
func createManifest() throws -> PrivacyManifest {
37+
// TODO(ncooke3): Implement.
38+
return PrivacyManifest()
39+
}
40+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import ArgumentParser
16+
import Foundation
17+
18+
struct PrivacyManifestGenerator: ParsableCommand {
19+
@Argument(
20+
help: ArgumentHelp("The xcframework to create the Privacy Manifest for."),
21+
transform: URL.init(fileURLWithPath:)
22+
)
23+
var xcframework: URL
24+
25+
func validate() throws {
26+
guard xcframework.pathExtension == "xcframework" else {
27+
throw ValidationError("Given path does not end in `.xcframework`: \(xcframework.path)")
28+
}
29+
}
30+
31+
func run() throws {
32+
let wizard = PrivacyManifestWizard(xcframework: xcframework)
33+
34+
while let question = wizard.nextQuestion() {
35+
print(question)
36+
if let answer = readLine() {
37+
try wizard.processAnswer(answer)
38+
}
39+
}
40+
41+
let privacyManifest = try wizard.createManifest()
42+
print(privacyManifest)
43+
}
44+
}

0 commit comments

Comments
 (0)