Skip to content

Commit

Permalink
[Release Tooling] Initial xcprivacy file generation tooling (#12134)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncooke3 authored Nov 22, 2023
1 parent e8cd98f commit 8fe1ddc
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ReleaseTooling/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ let package = Package(
.executable(name: "zip-builder", targets: ["ZipBuilder"]),
.executable(name: "podspecs-tester", targets: ["PodspecsTester"]),
.executable(name: "manifest", targets: ["ManifestParser"]),
.executable(name: "privacy-manifest-generator", targets: ["PrivacyManifestGenerator"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", .exact("0.1.0")),
Expand Down Expand Up @@ -53,5 +54,12 @@ let package = Package(
.target(
name: "Utils"
),
.target(
name: "PrivacyManifestGenerator",
dependencies: ["ArgumentParser", "PrivacyKit"]
),
.target(
name: "PrivacyKit"
),
]
)
21 changes: 21 additions & 0 deletions ReleaseTooling/Sources/PrivacyKit/PrivacyManifest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation

/// Represents a Privacy Manifest as described in
/// https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
public struct PrivacyManifest {
public init() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation
import PrivacyKit

/// Provides an API to walk the client through the creation of a Privacy
/// Manifest via a series of questions.
final class PrivacyManifestWizard {
private let xcframework: URL

init(xcframework: URL) {
self.xcframework = xcframework
}

func nextQuestion() -> String? {
// TODO(ncooke3): Implement.
nil
}

func processAnswer(_ answer: String) throws {
// TODO(ncooke3): Implement.
}

func createManifest() throws -> PrivacyManifest {
// TODO(ncooke3): Implement.
return PrivacyManifest()
}
}
44 changes: 44 additions & 0 deletions ReleaseTooling/Sources/PrivacyManifestGenerator/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import ArgumentParser
import Foundation

struct PrivacyManifestGenerator: ParsableCommand {
@Argument(
help: ArgumentHelp("The xcframework to create the Privacy Manifest for."),
transform: URL.init(fileURLWithPath:)
)
var xcframework: URL

func validate() throws {
guard xcframework.pathExtension == "xcframework" else {
throw ValidationError("Given path does not end in `.xcframework`: \(xcframework.path)")
}
}

func run() throws {
let wizard = PrivacyManifestWizard(xcframework: xcframework)

while let question = wizard.nextQuestion() {
print(question)
if let answer = readLine() {
try wizard.processAnswer(answer)
}
}

let privacyManifest = try wizard.createManifest()
print(privacyManifest)
}
}

0 comments on commit 8fe1ddc

Please sign in to comment.