|
| 1 | +// swift-tools-version: 5.9 |
| 2 | +// The swift-tools-version declares the minimum version of Swift required to build this package. |
| 3 | + |
| 4 | +import PackageDescription |
| 5 | + |
| 6 | +enum Config: String, CaseIterable { |
| 7 | + static let name: String = "Alarm" |
| 8 | + |
| 9 | + case di = "DI" |
| 10 | + case data = "Data" |
| 11 | + case domain = "Domain" |
| 12 | + case presentation = "Presentation" |
| 13 | + |
| 14 | + var name: String { |
| 15 | + Config.name + rawValue |
| 16 | + } |
| 17 | + |
| 18 | + var path: String { |
| 19 | + "Sources/\(rawValue)" |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +let package = Package( |
| 24 | + name: Config.name, |
| 25 | + platforms: [.iOS(.v17)], |
| 26 | + products: [ |
| 27 | + .library( |
| 28 | + name: Config.name, |
| 29 | + targets: Config.allCases.map(\.name) |
| 30 | + ), |
| 31 | + .library( |
| 32 | + name: Config.di.name, |
| 33 | + targets: [ |
| 34 | + Config.di.name, |
| 35 | + Config.presentation.name |
| 36 | + ] |
| 37 | + ) |
| 38 | + ], |
| 39 | + dependencies: [ |
| 40 | + .package(name: "DI", path: "../DI"), |
| 41 | + .package(name: "Common", path: "../Common"), |
| 42 | + .package(name: "Infrastructure", path: "../Infrastructure"), |
| 43 | + ], |
| 44 | + targets: [ |
| 45 | + .target( |
| 46 | + config: .di, |
| 47 | + dependencies: [ |
| 48 | + .target(config: .domain), |
| 49 | + .target(config: .data), |
| 50 | + .target(config: .presentation), |
| 51 | + .product(name: "DI", package: "DI"), |
| 52 | + .product(name: "AppDI", package: "DI"), |
| 53 | + .product(name: "NetworkInterface", package: "Infrastructure"), |
| 54 | + ], |
| 55 | + ), |
| 56 | + // Domain: 독립적 (외부 의존성 없음) |
| 57 | + .target(config: .domain), |
| 58 | + |
| 59 | + // Data |
| 60 | + .target( |
| 61 | + config: .data, |
| 62 | + dependencies: [ |
| 63 | + .target(config: .domain), |
| 64 | + .product(name: "NetworkInterface", package: "Infrastructure"), |
| 65 | + .product(name: "Util", package: "Common"), |
| 66 | + ] |
| 67 | + ), |
| 68 | + |
| 69 | + // Presentation: Domain, DesignSystem, Layout에 의존 |
| 70 | + .target( |
| 71 | + config: .presentation, |
| 72 | + dependencies: [ |
| 73 | + .target(config: .domain), |
| 74 | + .product(name: "DesignSystem", package: "Common"), |
| 75 | + ], |
| 76 | + ) |
| 77 | + |
| 78 | + ] |
| 79 | +) |
| 80 | + |
| 81 | +extension Target { |
| 82 | + static func target( |
| 83 | + config: Config, |
| 84 | + dependencies: [Dependency] = [], |
| 85 | + exclude: [String] = [], |
| 86 | + sources: [String]? = nil, |
| 87 | + resources: [Resource]? = nil, |
| 88 | + publicHeadersPath: String? = nil, |
| 89 | + packageAccess: Bool = false, |
| 90 | + cSettings: [CSetting]? = nil, |
| 91 | + cxxSettings: [CXXSetting]? = nil, |
| 92 | + swiftSettings: [SwiftSetting]? = nil, |
| 93 | + linkerSettings: [LinkerSetting]? = nil, |
| 94 | + plugins: [PluginUsage]? = nil, |
| 95 | + ) -> Target { |
| 96 | + return .target( |
| 97 | + name: config.name, |
| 98 | + dependencies: dependencies, |
| 99 | + path: config.path, |
| 100 | + exclude: exclude, |
| 101 | + sources: sources, |
| 102 | + resources: resources, |
| 103 | + publicHeadersPath: publicHeadersPath, |
| 104 | + packageAccess: packageAccess, |
| 105 | + cSettings: cSettings, |
| 106 | + cxxSettings: cxxSettings, |
| 107 | + swiftSettings: swiftSettings, |
| 108 | + linkerSettings: linkerSettings, |
| 109 | + plugins: plugins) |
| 110 | + } |
| 111 | +} |
| 112 | + |
| 113 | +extension Target.Dependency { |
| 114 | + static func target(config: Config) -> Self { |
| 115 | + return .target(name: config.name) |
| 116 | + } |
| 117 | +} |
0 commit comments