diff --git a/Plugins/DependencyPlugin/ProjectDescriptionHelpers/Dependency+Project.swift b/Plugins/DependencyPlugin/ProjectDescriptionHelpers/Dependency+Project.swift index ef71062..42f0c76 100644 --- a/Plugins/DependencyPlugin/ProjectDescriptionHelpers/Dependency+Project.swift +++ b/Plugins/DependencyPlugin/ProjectDescriptionHelpers/Dependency+Project.swift @@ -7,6 +7,9 @@ import ProjectDescription +/// 프로젝트 내 모듈 및 기능별 종속성을 체계적으로 관리하기 위한 유틸리티를 제공 +/// 새로운 모듈이나 기능이 추가되더라도 해당 파일만 업데이트하면 되어 유지보수가 용이합니다. + public extension Dep { struct Features { public struct Main {} @@ -17,36 +20,58 @@ public extension Dep { struct Modules {} } -// MARK: - Root +// MARK: - Root: 프로젝트의 핵심 모듈에 대한 종속성을 정의 public extension Dep { static let data = Dep.project(target: "Data", path: .data) - + static let domain = Dep.project(target: "Domain", path: .domain) static let core = Dep.project(target: "Core", path: .core) } -// MARK: - Modules +// MARK: - Modules: 프로젝트 내 모듈 단위 종속성을 정의 public extension Dep.Modules { - static let dsKit = Dep.project(target: "DSKit", path: .relativeToModules("DSKit")) + static let dsKit = Dep.project( + target: "DSKit", + path: .relativeToModules("DSKit") + ) - static let networks = Dep.project(target: "Networks", path: .relativeToModules("Networks")) + static let networks = Dep.project( + target: "Networks", + path: .relativeToModules("Networks") + ) - static let thirdPartyLibs = Dep.project(target: "ThirdPartyLibs", path: .relativeToModules("ThirdPartyLibs")) + static let thirdPartyLibs = Dep.project( + target: "ThirdPartyLibs", + path: .relativeToModules("ThirdPartyLibs") + ) } // MARK: - Features public extension Dep.Features { - static func project(name: String, group: String) -> Dep { .project(target: "\(group)\(name)", path: .relativeToFeature("\(group)\(name)")) } + static func project(name: String, group: String) -> Dep { + .project( + target: "\(group)\(name)", + path: .relativeToFeature("\(group)\(name)") + ) + } - static let BaseFeatureDependency = TargetDependency.project(target: "BaseFeatureDependency", path: .relativeToFeature("BaseFeatureDependency")) + static let BaseFeatureDependency = Dep.project( + target: "BaseFeatureDependency", + path: .relativeToFeature("BaseFeatureDependency") + ) - static let RootFeature = TargetDependency.project(target: "RootFeature", path: .relativeToFeature("RootFeature")) + static let RootFeature = Dep.project( + target: "RootFeature", + path: .relativeToFeature("RootFeature") + ) } +//TODO: 폴더별로 분기처리하기 위해서 이런식으로 했다면 하나의 그룹이름만 주입해서 만드는게 좋지않나? + public extension Dep.Features.Main { static let group = "Main" diff --git a/Plugins/DependencyPlugin/ProjectDescriptionHelpers/Dependency+SPM.swift b/Plugins/DependencyPlugin/ProjectDescriptionHelpers/Dependency+SPM.swift index fc651a2..72b5e21 100644 --- a/Plugins/DependencyPlugin/ProjectDescriptionHelpers/Dependency+SPM.swift +++ b/Plugins/DependencyPlugin/ProjectDescriptionHelpers/Dependency+SPM.swift @@ -7,6 +7,9 @@ import ProjectDescription +/// TargetDependency의 확장을 통해 +/// 프로젝트 내 외부 라이브러리 종속성을 보다 체계적으로 관리하기 위한 유틸리티를 제공하는 파일 + public extension TargetDependency { enum SPM {} enum Carthage {} diff --git a/Plugins/DependencyPlugin/ProjectDescriptionHelpers/PathExtension.swift b/Plugins/DependencyPlugin/ProjectDescriptionHelpers/PathExtension.swift index 0e6715b..11f0b59 100644 --- a/Plugins/DependencyPlugin/ProjectDescriptionHelpers/PathExtension.swift +++ b/Plugins/DependencyPlugin/ProjectDescriptionHelpers/PathExtension.swift @@ -7,27 +7,36 @@ import ProjectDescription +/// ProjectDescription.Path의 확장을 통해 +/// 프로젝트 내 경로를 보다 간결하고 직관적으로 관리하기 위한 유틸리티를 제공하는 파일 + public extension ProjectDescription.Path { + /// 기능 폴더에 대한 상대 경로를 생성 static func relativeToFeature(_ path: String) -> Self { return .relativeToRoot("Projects/Features/\(path)") } + /// 모듈 폴더에 대한 상대 경로를 생성 static func relativeToModules(_ path: String) -> Self { return .relativeToRoot("Projects/Modules/\(path)") } + /// 각각 앱 폴더에 대한 경로를 반환하는 속성 static var app: Self { return .relativeToRoot("Projects/App") } + /// 각각 데이터 폴더에 대한 경로를 반환하는 속성 static var data: Self { return .relativeToRoot("Projects/Data") } + /// 각각 도메인 폴더에 대한 경로를 반환하는 속성 static var domain: Self { return .relativeToRoot("Projects/Domain") } + /// 각각 코어 폴더에 대한 경로를 반환하는 속성 static var core: Self { return .relativeToRoot("Projects/Core") } diff --git a/Projects/Features/BaseFeatureDependency/Sources/ViewControllable.swift b/Projects/Features/BaseFeatureDependency/Sources/ViewControllable.swift new file mode 100644 index 0000000..d8b1d4a --- /dev/null +++ b/Projects/Features/BaseFeatureDependency/Sources/ViewControllable.swift @@ -0,0 +1,26 @@ +// +// ViewControllable.swift +// BaseFeatureDependency +// +// Created by 류희재 on 7/4/24. +// Copyright © 2024 Weather-iOS. All rights reserved. +// + +import UIKit + +public protocol ViewControllable { + var viewController: UIViewController { get } + var asNavigationController: UINavigationController { get } +} +public extension ViewControllable where Self: UIViewController { + var viewController: UIViewController { + return self + } + + var asNavigationController: UINavigationController { + return self as? UINavigationController + ?? UINavigationController(rootViewController: self) + } +} + +extension UIViewController: ViewControllable {}