Skip to content

Commit

Permalink
[Chore] 중복 파라미터 생략 DO-SOPT-iOS-Part#18
Browse files Browse the repository at this point in the history
  • Loading branch information
HELLOHIDI committed Jul 1, 2024
1 parent 642b55f commit c12de37
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 43 deletions.
22 changes: 12 additions & 10 deletions Plugins/EnvPlugin/ProjectDescriptionHelpers/Enviroment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@

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: "17.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"
)
2 changes: 1 addition & 1 deletion Projects/App/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import DependencyPlugin
import EnvPlugin

let project = Project.makeModule(
name: Environment.workspaceName,
name: env.workspaceName,
targets: [.app, .unitTest],
internalDependencies: [
.data,
Expand Down
70 changes: 39 additions & 31 deletions Tuist/ProjectDescriptionHelpers/Project+Templates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@ public extension Project {
/// Discussion/Overview
///
/// - Parameters:
/// - [param]: [description]
/// - name: 프로젝트 이름 (모듈 이름)
/// - targets: 빌드할 타겟의 대상
/// - organizationName: organization 이름
/// - packages:SPM의 package
/// - internalDependencies: 내부 의존성
/// - externalDependencies: 외부 의존성
/// - interfaceDependencies: 인터페이스 의존성
/// - sources: 소스 파일
/// - hasResourcces: 리소스 파일 포함 여부

///
/// - Returns: [description]
/// - Warning: [description]
/// - Author: [name]
Expand All @@ -30,8 +40,6 @@ public extension Project {
) -> Project {
let configurationName: ConfigurationName = "Development"
let hasDynamicFramework = targets.contains(.dynamicFramework)
let deploymentTarget = Environment.deploymentTarget
let platform = Environment.platform
let baseSetting: SettingsDictionary = [:]

var projectTargets: [Target] = []
Expand All @@ -46,10 +54,10 @@ public extension Project {

let target = Target(
name: name,
platform: platform,
platform: env.platform,
product: .app,
bundleId: "\(Environment.bundlePrefix).\(bundleSuffix)",
deploymentTarget: deploymentTarget,
bundleId: "\(env.bundlePrefix).\(bundleSuffix)",
deploymentTarget: env.deploymentTarget,
//infoPlist에 .extendingDefault로 Info.plsit에 추가 내용을 넣어준 이유는 tuist에서 .default 만들어주는 Info.plist는 앱을 실행할 때 화면이 어딘가 나사가 빠진상태로 실행되기 때문입니다.
infoPlist: .extendingDefault(with: infoPlist),
sources: .sources,
Expand All @@ -72,10 +80,10 @@ public extension Project {
let setting = baseSetting
let target = Target(
name: "\(name)Interface",
platform: platform,
platform: env.platform,
product: .framework,
bundleId: "\(Environment.bundlePrefix).\(name)Interface",
deploymentTarget: deploymentTarget,
bundleId: "\(env.bundlePrefix).\(name)Interface",
deploymentTarget: env.deploymentTarget,
infoPlist: .default,
sources: .interface,
dependencies: internalDependencies,
Expand All @@ -95,10 +103,10 @@ public extension Project {

let target = Target(
name: name,
platform: platform,
platform: env.platform,
product: hasDynamicFramework ? .framework : .staticFramework,
bundleId: "\(Environment.bundlePrefix).\(name)",
deploymentTarget: deploymentTarget,
bundleId: "\(env.bundlePrefix).\(name)",
deploymentTarget: env.deploymentTarget,
infoPlist: .default,
sources: .sources,
resources: hasResources ? [.glob(pattern: "Resources/**", excluding: [])] : [],
Expand All @@ -117,10 +125,10 @@ public extension Project {

let target = Target(
name: "\(name)Demo",
platform: platform,
platform: env.platform,
product: .app,
bundleId: "\(Environment.bundlePrefix).\(name)Demo",
deploymentTarget: deploymentTarget,
bundleId: "\(env.bundlePrefix).\(name)Demo",
deploymentTarget: env.deploymentTarget,
infoPlist: .extendingDefault(with: Project.demoInfoPlist),
sources: .demoSources,
resources: [.glob(pattern: "Demo/Resources/**", excluding: ["Demo/Resources/dummy.txt"])],
Expand All @@ -137,10 +145,10 @@ public extension Project {

let target = Target(
name: "\(name)Tests",
platform: platform,
platform: env.platform,
product: .unitTests,
bundleId: "\(Environment.bundlePrefix).\(name)Tests",
deploymentTarget: deploymentTarget,
bundleId: "\(env.bundlePrefix).\(name)Tests",
deploymentTarget: env.deploymentTarget,
infoPlist: .default,
sources: .unitTests,
resources: [.glob(pattern: "Tests/Resources/**", excluding: [])],
Expand All @@ -165,7 +173,7 @@ public extension Project {

return Project(
name: name,
organizationName: Environment.workspaceName,
organizationName: env.workspaceName,
packages: packages,
settings: .settings(configurations: XCConfig.project),
targets: projectTargets,
Expand All @@ -179,13 +187,13 @@ extension Project {
static let appSchemes: [Scheme] = [
// PROD API, debug scheme
.init(
name: "\(Environment.workspaceName)-DEV",
name: "\(env.workspaceName)-DEV",
shared: true,
buildAction: .buildAction(targets: ["\(Environment.workspaceName)"]),
buildAction: .buildAction(targets: ["\(env.workspaceName)"]),
testAction: .targets(
["\(Environment.workspaceName)Tests", "\(Environment.workspaceName)UITests"],
["\(env.workspaceName)Tests", "\(env.workspaceName)UITests"],
configuration: "Development",
options: .options(coverage: true, codeCoverageTargets: ["\(Environment.workspaceName)"])
options: .options(coverage: true, codeCoverageTargets: ["\(env.workspaceName)"])
),
runAction: .runAction(configuration: "Development"),
archiveAction: .archiveAction(configuration: "Development"),
Expand All @@ -194,13 +202,13 @@ extension Project {
),
// Test API, debug scheme
.init(
name: "\(Environment.workspaceName)-Test",
name: "\(env.workspaceName)-Test",
shared: true,
buildAction: .buildAction(targets: ["\(Environment.workspaceName)"]),
buildAction: .buildAction(targets: ["\(env.workspaceName)"]),
testAction: .targets(
["\(Environment.workspaceName)Tests", "\(Environment.workspaceName)UITests"],
["\(env.workspaceName)Tests", "\(env.workspaceName)UITests"],
configuration: "Test",
options: .options(coverage: true, codeCoverageTargets: ["\(Environment.workspaceName)"])
options: .options(coverage: true, codeCoverageTargets: ["\(env.workspaceName)"])
),
runAction: .runAction(configuration: "Test"),
archiveAction: .archiveAction(configuration: "Test"),
Expand All @@ -209,19 +217,19 @@ extension Project {
),
// Test API, release scheme
.init(
name: "\(Environment.workspaceName)-QA",
name: "\(env.workspaceName)-QA",
shared: true,
buildAction: .buildAction(targets: ["\(Environment.workspaceName)"]),
buildAction: .buildAction(targets: ["\(env.workspaceName)"]),
runAction: .runAction(configuration: "QA"),
archiveAction: .archiveAction(configuration: "QA"),
profileAction: .profileAction(configuration: "QA"),
analyzeAction: .analyzeAction(configuration: "QA")
),
// PROD API, release scheme
.init(
name: "\(Environment.workspaceName)-PROD",
name: "\(env.workspaceName)-PROD",
shared: true,
buildAction: .buildAction(targets: ["\(Environment.workspaceName)"]),
buildAction: .buildAction(targets: ["\(env.workspaceName)"]),
runAction: .runAction(configuration: "PROD"),
archiveAction: .archiveAction(configuration: "PROD"),
profileAction: .profileAction(configuration: "PROD"),
Expand Down
2 changes: 1 addition & 1 deletion Tuist/ProjectDescriptionHelpers/Scheme+Template.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extension Scheme {
}

static func makeDemoAppTestScheme() -> Scheme { // 데모테스트앱
let targetName = "\(Environment.workspaceName)-Demo"
let targetName = "\(env.workspaceName)-Demo"
return Scheme(
name: "\(targetName)-Test",
shared: true,
Expand Down

0 comments on commit c12de37

Please sign in to comment.