-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Release Tooling] Initial xcprivacy file generation tooling (#12134)
- Loading branch information
Showing
4 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} | ||
} |
40 changes: 40 additions & 0 deletions
40
ReleaseTooling/Sources/PrivacyManifestGenerator/PrivacyManifestWizard.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
44
ReleaseTooling/Sources/PrivacyManifestGenerator/main.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |