spm_swift_package/domain/platform/
platform_validator.rs

1use crate::domain::file::project_file::*;
2use std::collections::HashMap;
3
4/// Validates and generates the appropriate platform configuration
5/// Responsible for creating the Package.swift file using the selected platform
6pub struct PlatformValidator;
7
8impl PlatformValidator {
9	/// Generates the platform configuration for the project
10	/// Creates a Package.swift file based on the selected platform and plugin flag
11	///
12	/// * `project_name` - name of the generated Swift package
13	/// * `platform` - vector containing the selected platform
14	/// * `is_plugin` - indicates whether the package is a Swift plugin
15	pub fn generate_platform(project_name: &str, platform: Vec<&str>, is_plugin: bool) {
16		let platforms = HashMap::from([
17			("iOS", "26"),
18			("macOS", "26"),
19			("watchOS", "26"),
20			("tvOS", "26"),
21			("visionOS", "26"),
22		]);
23
24		for (key, version) in platforms {
25			if platform.contains(&key) {
26				let _ = ProjectFile::create_package(project_name, key, version, is_plugin);
27			}
28		}
29	}
30}