Skip to content

Commit fe6e9b0

Browse files
author
Michalis Karagiorgos
committed
add documentation
1 parent cbe8dec commit fe6e9b0

3 files changed

Lines changed: 82 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Sources/Configuration/Configuration.swift

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,61 @@
77
/// alignment of files, dependencies, and frameworks across grouped targets.
88
/// - ForbiddenResourcesProcessor validates `forbiddenResourceSets` to ensure no disallowed resource paths exist.
99
/// - XcodeProjectParser consults `duplicatesValidationExcludedTargets` to skip duplicate checks for specified targets.
10+
///
11+
/// Example JSON (full):
12+
/// ```json
13+
/// {
14+
/// "name": "MyProject",
15+
/// "fileMembershipSets": [
16+
/// {
17+
/// "targets": ["App", "AppStaging", "AppProd"],
18+
/// "exclusive": {
19+
/// "AppStaging": {
20+
/// "files": ["Config/Staging/*", "Features/DebugPanel/"],
21+
/// "dependencies": ["StagingAnalytics"],
22+
/// "frameworks": ["StagingSDK"]
23+
/// },
24+
/// "AppProd": {
25+
/// "files": ["Config/Prod/*"],
26+
/// "dependencies": ["ProdAnalytics"],
27+
/// "frameworks": ["ProdSDK"]
28+
/// }
29+
/// }
30+
/// },
31+
/// {
32+
/// "targets": ["Widget", "WidgetExtension"],
33+
/// "exclusive": {
34+
/// "WidgetExtension": {
35+
/// "files": ["WidgetExtensionSpecific/*"],
36+
/// "dependencies": ["WidgetExtensionSupport"],
37+
/// "frameworks": []
38+
/// }
39+
/// }
40+
/// }
41+
/// ],
42+
/// "forbiddenResourceSets": [
43+
/// {
44+
/// "targets": ["App", "AppStaging", "AppProd"],
45+
/// "paths": ["/Debug/", "Temporary/"]
46+
/// },
47+
/// {
48+
/// "targets": ["Widget"],
49+
/// "paths": ["LargeAssets/"]
50+
/// }
51+
/// ],
52+
/// "duplicatesValidationExcludedTargets": ["Tests", "UITests"]
53+
/// }
54+
/// ```
55+
///
56+
/// Minimal JSON (only required keys):
57+
/// ```json
58+
/// {
59+
/// "name": "MyProject",
60+
/// "fileMembershipSets": [
61+
/// { "targets": ["App"] }
62+
/// ]
63+
/// }
64+
/// ```
1065
struct Configuration: Codable, Equatable {
1166
/// Logical name of the Xcode project (without the `.xcodeproj` extension).
1267
/// Used to construct the project path.

Sources/XcodeTargets.swift

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,38 @@ import ArgumentParser
22
import Foundation
33
import XcodeProj
44

5+
/// Entry point for the `xcode-targets` command line tool.
6+
///
7+
/// The command loads and validates an `.xcode-targets.json` configuration file and
8+
/// processes Xcode project targets to detect duplicates, exclusives, and forbidden resources.
9+
///
10+
/// Usage example:
11+
/// xcode-targets --config path/to/.xcode-targets.json --rootPath /path/to/project --verbose
12+
///
13+
/// Provide `--verbose` (or `-v`) to enable additional diagnostic output.
514
@main
615
struct XcodeTargets: ParsableCommand {
7-
// @Option(name: [.short, .customLong("config")], help: "The path of `.xcode-targets.json`.")
8-
var configurationPath: String? = ".xcode-targets.json"
16+
/// The path to the `.xcode-targets.json` configuration file.
17+
/// If omitted, the tool attempts to locate a configuration in the current directory.
18+
@Option(name: [.short, .customLong("config")], help: "The path of `.xcode-targets.json`.")
19+
var configurationPath: String? //= ".xcode-targets.json"
920

10-
// @Option(
11-
// name: .shortAndLong,
12-
// help: "The rootPath of your project. Defaults to current directory."
13-
// )
14-
var rootPath: String? = "/Users/m.karagiorgos/iosnative/"
21+
/// The root path of the project to analyze.
22+
/// Defaults to the current working directory when not provided.
23+
@Option(
24+
name: .shortAndLong,
25+
help: "The rootPath of your project. Defaults to current directory."
26+
)
27+
var rootPath: String? //= "/Users/m.karagiorgos/iosnative/"
1528

16-
// @Option(name: .shortAndLong, help: "Flag to enable verbose output.")
29+
/// Flag to enable verbose output for diagnostic purposes.
30+
@Option(name: .shortAndLong, help: "Flag to enable verbose output.")
1731
var verbose: Bool = false
1832

33+
/// Executes the command: loads configuration, initializes dependencies, and runs processing.
34+
///
35+
/// - Throws: Rethrows any errors encountered during configuration loading, file system access,
36+
/// or Xcode project parsing and validation.
1937
func run() throws {
2038
let fileSystem = FileSystem(
2139
fileManager: FileManager.default,

0 commit comments

Comments
 (0)