|
| 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 = "AppCore" |
| 8 | + |
| 9 | + case di = "DI" |
| 10 | + |
| 11 | + var name: String { |
| 12 | + return "\(Config.name)\(rawValue)" |
| 13 | + } |
| 14 | + |
| 15 | + var path: String { |
| 16 | + "Sources/\(rawValue)" |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +let package = Package( |
| 21 | + name: Config.name, |
| 22 | + platforms: [.iOS(.v17)], |
| 23 | + products: [ |
| 24 | + .library( |
| 25 | + name: "AppCore", |
| 26 | + targets: Config.allCases.map(\.name) |
| 27 | + ), |
| 28 | + ], |
| 29 | + dependencies: [ |
| 30 | + .package(name: "Intro", path: "../Intro"), |
| 31 | + .package(name: "Login", path: "../Login"), |
| 32 | + .package(name: "Home", path: "../Home"), |
| 33 | + .package(name: "Community", path: "../Community"), |
| 34 | + .package(name: "MyPage", path: "../MyPage"), |
| 35 | + .package(name: "Alarm", path: "../Alarm"), |
| 36 | + |
| 37 | + .package(name: "3rdParty", path: "../3rdParty"), |
| 38 | + .package(name: "Common", path: "../Common"), |
| 39 | + .package(name: "Infrastructure", path: "../Infrastructure"), |
| 40 | + ], |
| 41 | + targets: [ |
| 42 | + .target( |
| 43 | + config: .di, |
| 44 | + dependencies: [ |
| 45 | + .product(name: "DataSources", package: "Common"), |
| 46 | + .product(name: "Managers", package: "Common"), |
| 47 | + .product(name: "NetworkInterface", package: "Infrastructure"), |
| 48 | + .product(name: "NetworkImpl", package: "Infrastructure"), |
| 49 | + .product(name: "FCMService", package: "3rdParty"), |
| 50 | + |
| 51 | + .product(name: "IntroDI", package: "Intro"), |
| 52 | + .product(name: "LoginDI", package: "Login"), |
| 53 | + .product(name: "HomeDI", package: "Home"), |
| 54 | + .product(name: "CommunityDI", package: "Community"), |
| 55 | + .product(name: "MyPageDI", package: "MyPage"), |
| 56 | + .product(name: "AlarmDI", package: "Alarm"), |
| 57 | + ] |
| 58 | + ) |
| 59 | + ] |
| 60 | +) |
| 61 | + |
| 62 | +extension Target { |
| 63 | + static func target( |
| 64 | + config: Config, |
| 65 | + dependencies: [Dependency] = [], |
| 66 | + exclude: [String] = [], |
| 67 | + sources: [String]? = nil, |
| 68 | + resources: [Resource]? = nil, |
| 69 | + publicHeadersPath: String? = nil, |
| 70 | + packageAccess: Bool = false, |
| 71 | + cSettings: [CSetting]? = nil, |
| 72 | + cxxSettings: [CXXSetting]? = nil, |
| 73 | + swiftSettings: [SwiftSetting]? = nil, |
| 74 | + linkerSettings: [LinkerSetting]? = nil, |
| 75 | + plugins: [PluginUsage]? = nil, |
| 76 | + ) -> Target { |
| 77 | + return .target( |
| 78 | + name: config.name, |
| 79 | + dependencies: dependencies, |
| 80 | + path: config.path, |
| 81 | + exclude: exclude, |
| 82 | + sources: sources, |
| 83 | + resources: resources, |
| 84 | + publicHeadersPath: publicHeadersPath, |
| 85 | + packageAccess: packageAccess, |
| 86 | + cSettings: cSettings, |
| 87 | + cxxSettings: cxxSettings, |
| 88 | + swiftSettings: swiftSettings, |
| 89 | + linkerSettings: linkerSettings, |
| 90 | + plugins: plugins) |
| 91 | + } |
| 92 | +} |
| 93 | + |
| 94 | +extension Target.Dependency { |
| 95 | + static func target(config: Config) -> Self { |
| 96 | + return .target(name: config.name) |
| 97 | + } |
| 98 | +} |
0 commit comments