Skip to content

Commit

Permalink
Merge pull request #19 from HELLOHIDI/Refactor/#18
Browse files Browse the repository at this point in the history
[Refactor] #18 - 트위스트 세팅 리펙토링하기
  • Loading branch information
HELLOHIDI authored Jul 5, 2024
2 parents fde14b2 + 1425994 commit eaa13a3
Show file tree
Hide file tree
Showing 104 changed files with 2,060 additions and 182 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions Configurations/Targets/iOS-Demo.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// iOS-Demo.xcconfig
// Manifests
//
// Created by 류희재 on 6/28/24.
//

// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974
9 changes: 9 additions & 0 deletions Configurations/Targets/iOS-Framework.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// iOS-Framework.xcconfig
// Manifests
//
// Created by 류희재 on 6/28/24.
//

// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974
9 changes: 9 additions & 0 deletions Configurations/Targets/iOS-Tests.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// iOS-Tests.xcconfig
// Manifests
//
// Created by 류희재 on 6/28/24.
//

// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974
3 changes: 3 additions & 0 deletions Plugins/ConfigPlugin/Plugin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ProjectDescription

let configPlugin = Plugin(name: "ConfigPlugin")
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import Foundation
import ProjectDescription

/// 빌드할 환경에 대한 설정

/// Target 분리 (The Modular Architecture 기반으로 분리했습니다)


/// DEV : 실제 프로덕트 BaseURL을 사용하는 debug scheme
/// TEST : 테스트 BaseURL을 사용하는 debug scheme
/// QA : 테스트 BaseURL을 사용하는 release scheme
/// RELEASE : 실제 프로덕트 BaseURL을 사용하는 release scheme


public struct XCConfig {
private struct Path {
static var framework: ProjectDescription.Path { .relativeToRoot("Configurations/Targets/iOS-Framework.xcconfig") }
static var demo: ProjectDescription.Path { .relativeToRoot("Configurations/Targets/iOS-Demo.xcconfig") }
static var tests: ProjectDescription.Path { .relativeToRoot("Configurations/Targets/iOS-Tests.xcconfig") }
static func project(_ config: String) -> ProjectDescription.Path { .relativeToRoot("Configurations/Base/Projects/Project-\(config).xcconfig") }
}

public static let framework: [Configuration] = [
.debug(name: "Development", xcconfig: Path.framework),
.debug(name: "Test", xcconfig: Path.framework),
.release(name: "QA", xcconfig: Path.framework),
.release(name: "PROD", xcconfig: Path.framework),
]

public static let tests: [Configuration] = [
.debug(name: "Development", xcconfig: Path.tests),
.debug(name: "Test", xcconfig: Path.tests),
.release(name: "QA", xcconfig: Path.tests),
.release(name: "PROD", xcconfig: Path.tests),
]
public static let demo: [Configuration] = [
.debug(name: "Development", xcconfig: Path.demo),
.debug(name: "Test", xcconfig: Path.demo),
.release(name: "QA", xcconfig: Path.demo),
.release(name: "PROD", xcconfig: Path.demo),
]
public static let project: [Configuration] = [
.debug(name: "Development", xcconfig: Path.project("Development")),
.debug(name: "Test", xcconfig: Path.project("Test")),
.release(name: "QA", xcconfig: Path.project("QA")),
.release(name: "PROD", xcconfig: Path.project("PROD")),
]
}
2 changes: 1 addition & 1 deletion Plugins/DependencyPlugin/Plugin.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import ProjectDescription

let dependencyPlugin = Plugin(name: "DependencyPlugin")
let dependencyPlugin = Plugin(name: "DependencyPlugin")
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

import ProjectDescription

/// 프로젝트 내 모듈 및 기능별 종속성을 체계적으로 관리하기 위한 유틸리티를 제공
/// 새로운 모듈이나 기능이 추가되더라도 해당 파일만 업데이트하면 되어 유지보수가 용이합니다.

public extension Dep {
struct Features {
public struct Main {}
Expand All @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

import ProjectDescription

/// TargetDependency의 확장을 통해
/// 프로젝트 내 외부 라이브러리 종속성을 보다 체계적으로 관리하기 위한 유틸리티를 제공하는 파일

public extension TargetDependency {
enum SPM {}
enum Carthage {}
Expand All @@ -21,4 +24,5 @@ public extension TargetDependency.SPM {
static let RxSwift = TargetDependency.external(name: "RxSwift")
static let RxCocoa = TargetDependency.external(name: "RxCocoa")
static let RxRelay = TargetDependency.external(name: "RxRelay")
static let ReactorKit = TargetDependency.external(name: "ReactorKit")
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
23 changes: 13 additions & 10 deletions Plugins/EnvPlugin/ProjectDescriptionHelpers/Enviroment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@

import ProjectDescription

public enum Environment {
public static let workspaceName = "Weather-iOS"
}
/// 프로젝트 환경 관련 파일입니다

public extension Project {
enum Environment {
public static let workspaceName = "Weather-iOS"
public static let deploymentTarget = DeploymentTarget.iOS(targetVersion: "16.0", devices: [.iphone])
public static let platform = Platform.iOS
public static let bundlePrefix = "com.Weather-iOS"
}
public struct ProjectEnvironment {
public let workspaceName: String
public let deploymentTarget: DeploymentTarget
public let platform: Platform
public let bundlePrefix: String
}

public let env = ProjectEnvironment(
workspaceName: "Weather-iOS",
deploymentTarget: DeploymentTarget.iOS(targetVersion: "17.0", devices: [.iphone]),
platform: .iOS,
bundlePrefix: "com.Weather-iOS"
)
17 changes: 5 additions & 12 deletions Plugins/EnvPlugin/ProjectDescriptionHelpers/InfoPlist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@

import ProjectDescription

/// InfoPList를 정리해둔 파일이빈다
///
public extension Project {
static let appInfoPlist: [String: InfoPlist.Value] = [
static let appInfoPlist: [String: Plist.Value] = [
"BASE_URL": "https://api.openweathermap.org/data/2.5",
"API_KEY": "7618d35ff394f5dd39212928a3a4692f",
"CFBundleShortVersionString": "1.0.0",
"CFBundleDevelopmentRegion": "ko",
"CFBundleVersion": "1",
"CFBundleIdentifier": "com.Weather-iOS.release",
"CFBundleIdentifier": "com.Weather-iOS.$(PRODUCT_MODULE_NAME)",
"CFBundleDisplayName": "Weather-iOS",
"UILaunchStoryboardName": "LaunchScreen",
"UIApplicationSceneManifest": [
Expand All @@ -38,18 +40,9 @@ public extension Project {
"App Transport Security Settings": ["Allow Arbitrary Loads": true],
"NSAppTransportSecurity": ["NSAllowsArbitraryLoads": true],
"ITSAppUsesNonExemptEncryption": false,
// "UIUserInterfaceStyle": "Dark",
// "CFBundleURLTypes": [
// [
// "CFBundleTypeRole": "Editor",
// "CFBundleURLName": "sopt-makers",
// "CFBundleURLSchemes": ["sopt-makers"]
// ]
// ],
// "UIBackgroundModes": ["remote-notification"]
]

static let demoInfoPlist: [String: InfoPlist.Value] = [
static let demoInfoPlist: [String: Plist.Value] = [
"CFBundleShortVersionString": "1.0.0",
"CFBundleDevelopmentRegion": "ko",
"CFBundleVersion": "1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// SettingDictionary+.swift
// EnvPlugin
//
// Created by 류희재 on 6/26/24.
//

import ProjectDescription

// 아직 여기의 필요성은 못 느끼는중 무슨 역할을 하게 될지 궁금하다!

public extension SettingsDictionary {
// allLoadSettings와 baseSettings는 빌드 설정 딕셔너리의 기본값을 정의
static let allLoadSettings: Self = [
"OTHER_LDFLAGS" : [
"$(inherited) -all_load",
"-Xlinker -interposable"
]
]

static let baseSettings: Self = [
"OTHER_LDFLAGS" : [
"$(inherited)",
"-ObjC"
]
]

func setProductBundleIdentifier(_ value: String = "com.iOS$(BUNDLE_ID_SUFFIX)") -> SettingsDictionary {
merging(["PRODUCT_BUNDLE_IDENTIFIER": SettingValue(stringLiteral: value)])
}

func setAssetcatalogCompilerAppIconName(_ value: String = "AppIcon$(BUNDLE_ID_SUFFIX)") -> SettingsDictionary {
merging(["ASSETCATALOG_COMPILER_APPICON_NAME": SettingValue(stringLiteral: value)])
}

func setBuildActiveArchitectureOnly(_ value: Bool) -> SettingsDictionary {
merging(["ONLY_ACTIVE_ARCH": SettingValue(stringLiteral: value ? "YES" : "NO")])
}

func setExcludedArchitectures(sdk: String = "iphonesimulator*", _ value: String = "arm64") -> SettingsDictionary {
merging(["EXCLUDED_ARCHS[sdk=\(sdk)]": SettingValue(stringLiteral: value)])
}

func setSwiftActiveComplationConditions(_ value: String) -> SettingsDictionary {
merging(["SWIFT_ACTIVE_COMPILATION_CONDITIONS": SettingValue(stringLiteral: value)])
}

func setAlwaysSearchUserPath(_ value: String = "NO") -> SettingsDictionary {
merging(["ALWAYS_SEARCH_USER_PATHS": SettingValue(stringLiteral: value)])
}

func setStripDebugSymbolsDuringCopy(_ value: String = "NO") -> SettingsDictionary {
merging(["COPY_PHASE_STRIP": SettingValue(stringLiteral: value)])
}

func setDynamicLibraryInstallNameBase(_ value: String = "@rpath") -> SettingsDictionary {
merging(["DYLIB_INSTALL_NAME_BASE": SettingValue(stringLiteral: value)])
}

func setSkipInstall(_ value: Bool = false) -> SettingsDictionary {
merging(["SKIP_INSTALL": SettingValue(stringLiteral: value ? "YES" : "NO")])
}

func setCodeSignManual() -> SettingsDictionary {
merging(["CODE_SIGN_STYLE": SettingValue(stringLiteral: "Manual")])
.merging(["DEVELOPMENT_TEAM": SettingValue(stringLiteral: "9K86FQHDLU")])
.merging(["CODE_SIGN_IDENTITY": SettingValue(stringLiteral: "$(CODE_SIGN_IDENTITY)")])
}

func setProvisioning() -> SettingsDictionary {
merging(["PROVISIONING_PROFILE_SPECIFIER": SettingValue(stringLiteral: "$(APP_PROVISIONING_PROFILE)")])
.merging(["PROVISIONING_PROFILE": SettingValue(stringLiteral: "$(APP_PROVISIONING_PROFILE)")])
}
}
14 changes: 6 additions & 8 deletions Projects/App/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import DependencyPlugin
import EnvPlugin

let project = Project.makeModule(
name: Environment.workspaceName,
product: .app,
dependencies: [
.Features.RootFeature,
.data
],
sources: ["Sources/**"],
resources: ["Resources/**"]
name: env.workspaceName,
targets: [.app, .unitTest],
internalDependencies: [
.data,
.Features.RootFeature
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit eaa13a3

Please sign in to comment.