Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TNT-80] Static Library에서도 Preview를 사용 가능하도록 Tuist 수정 #29

Merged
merged 4 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TnT/Projects/DI/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
@preconcurrency import ProjectDescription
@preconcurrency import ProjectDescriptionHelpers

let project = Project.module(name: "DI", resources: false)
//let project = Project.module(name: "DI", resources: false)


2 changes: 1 addition & 1 deletion TnT/Projects/Data/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
@preconcurrency import ProjectDescription
@preconcurrency import ProjectDescriptionHelpers

let project = Project.module(name: "Data", resources: false)
let project = Project.staticLibraryProejct(name: "Data", resource: false)
3 changes: 2 additions & 1 deletion TnT/Projects/DesignSystem/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
@preconcurrency import ProjectDescription
@preconcurrency import ProjectDescriptionHelpers

let project = Project.module(name: "DesignSystem", resources: true)
let project = Project.staticLibraryProejct(name: "DesignSystem", resource: true)
//dynamicFrameworkProject(name: "DesignSystem", resources: true)
11 changes: 5 additions & 6 deletions TnT/Projects/DesignSystem/Sources/Button/TBottomButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct TBottomButton: View {
/// 버튼의 제목 텍스트
public let title: String
/// 버튼의 상태
public let state: ButtonState
public let isEnable: Bool
/// 버튼이 탭되었을 때 실행할 동작 (옵셔널)
public var action: (() -> Void)

Expand All @@ -24,23 +24,22 @@ public struct TBottomButton: View {
/// - action: 버튼 탭 시 실행할 동작 (옵셔널)
public init(
title: String,
state: ButtonState,
isEnable: Bool,
action: (@escaping () -> Void)
) {
self.title = title
self.state = state
self.isEnable = isEnable
self.action = action
}

public var body: some View {
Button(title) {
action()
}
.typographyStyle(.heading4, with: state.textColor)
.typographyStyle(.heading4, with: isEnable ? ButtonState.true.textColor : ButtonState.false.textColor)
.padding(.vertical, 20)
.frame(maxWidth: .infinity)
.background(state.background)
.ignoresSafeArea()
.background(isEnable ? ButtonState.true.textColor : ButtonState.false.textColor)
}
}

Expand Down
2 changes: 1 addition & 1 deletion TnT/Projects/Domain/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
@preconcurrency import ProjectDescription
@preconcurrency import ProjectDescriptionHelpers

let project = Project.module(name: "Domain", resources: false)
let project = Project.staticLibraryProejct(name: "Domain", resource: false)

2 changes: 1 addition & 1 deletion TnT/Projects/Domain/Sources/DomainSoureDummy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
// Created by 박서연 on 1/4/25.
//

import Foundation
import SwiftUI
2 changes: 1 addition & 1 deletion TnT/Projects/Presentation/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
@preconcurrency import ProjectDescription
@preconcurrency import ProjectDescriptionHelpers

let project = Project.module(name: "Presentation", resources: false)
let project = Project.staticLibraryProejct(name: "Presentation", resource: false)

Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
// Created by 박서연 on 1/4/25.
//

import Foundation
import SwiftUI
2 changes: 1 addition & 1 deletion TnT/Projects/TnTApp/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
@preconcurrency import ProjectDescription
@preconcurrency import ProjectDescriptionHelpers

let project = Project.app
let project = Project.appProject()
3 changes: 2 additions & 1 deletion TnT/Projects/TnTApp/Sources/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import SwiftUI

struct ContentView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
Text("dasdasdf")
Text("Hello, World!")
}
}

Expand Down
14 changes: 14 additions & 0 deletions TnT/Tuist.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Tuist.swift
// Manifests
//
// Created by 박서연 on 1/22/25.
//

import ProjectDescription

let tuist = Tuist.init(
project: .tuist(
compatibleXcodeVersions: ["16.2"]
)
)
Comment on lines +10 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런 세팅이 있는 줄은 처음 알았네요..! 협업 시 너무 좋은 것 같습니다 👍👍

11 changes: 2 additions & 9 deletions TnT/Tuist/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@

let packageSettings = PackageSettings(
// Customize the product types for specific package product
// Default is .staticFramework
// productTypes: ["Alamofire": .framework,]
productTypes: [:],
baseSettings: .settings(
configurations: [
.debug(name: .debug),
.release(name: .release)
]
)
// Default is .staticFramework
productTypes: [:]
)
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
@preconcurrency import ProjectDescription

public extension Configuration {
// static func defaultSettings() -> Settings {
// return Settings.settings(
// configurations: [
// .debug(name: .debug, xcconfig: .relativeToRoot("Tuist/Config/Secrets.xcconfig")),
// .release(name: .release, xcconfig: .relativeToRoot("Tuist/Config/Secrets.xcconfig")),
// ],
// defaultSettings: DefaultSettings.recommended
// )
// }

static func defaultSettings() -> Settings {
return Settings.settings(
base: ["OTHER_LDFLAGS": ["-ObjC"]],
configurations: [
.debug(name: .debug, xcconfig: .relativeToRoot("Tuist/Config/Secrets.xcconfig")),
.release(name: .release, xcconfig: .relativeToRoot("Tuist/Config/Secrets.xcconfig")),
],
defaultSettings: DefaultSettings.recommended
)
return Settings.settings()
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,38 @@
@preconcurrency import ProjectDescription

let dependencyInfo: [DependencyInformation: [DependencyInformation]] = [
.TnTApp: [.Presentation],
.TnTApp: [.Presentation, .Data],
.Presentation: [.DesignSystem, .Domain, .ComposableArchitecture],
.Domain: [.Data, .SwiftDepedencies, .KakaoSDKUser],
.Data: [],
.DesignSystem: [.ComposableArchitecture, .Lottie],
.DI: []
.Domain: [.SwiftDepedencies],
.Data: [.Domain, .KakaoSDKUser],
.DesignSystem: [.Lottie],
]

public enum DependencyInformation: String, CaseIterable, Sendable {
case TnTApp = "TnTApp"
case Presentation = "Presentation"
case Domain = "Domain"
case Data = "Data"
case DI = "DI"
case DesignSystem = "DesignSystem"
case Lottie = "Lottie"
case ComposableArchitecture = "ComposableArchitecture"
case KakaoSDKUser = "KakaoSDKUser"
case SwiftDepedencies = "Dependencies"
}

extension DependencyInformation {
public func setDependency(module: DependencyInformation) -> TargetDependency {
switch self {
case .TnTApp:
return .project(target: self.rawValue, path: "Projects/TnTApp")
case .Presentation:
return .project(target: self.rawValue, path: "Projects/Presentation")
case .Domain:
return .project(target: self.rawValue, path: "Projects/Domain")
case .Data:
return .project(target: self.rawValue, path: "Projects/Data")
case .DI:
return .project(target: self.rawValue, path: "Projects/DI")
case .DesignSystem:
return .project(target: self.rawValue, path: "Projects/DesignSystem")
default:
return .project(target: "none", path: "")
public extension DependencyInformation {
static func dependencies(of name: String) -> [TargetDependency] {
guard let name = DependencyInformation(rawValue: name) else { return [] }
guard let modules: [DependencyInformation] = dependencyInfo[name] else { return [] }

return modules.map { module in
let name = module.rawValue

if externalDependency.contains(module) {
return .external(name: name)
} else {
return .project(target: name, path: .relativeToRoot("Projects/\(name)"))
}
Comment on lines +31 to +42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

더 깔끔해지고 모듈 확장성이 좋아졌네요! 👍👍

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

@preconcurrency import ProjectDescription

public let environmentName: String = "TnTApp"
public let environmentOrganizationName: String = "yapp25thTeamTnT"
public let environmentDeploymentTargets: DeploymentTargets = .iOS("17.0")
public let environmentPlatform: Platform = .iOS
public let environmentDestinations: Destinations = [.iPhone]
public enum Environment {
public static let appName: String = "TnTApp"
public static let organizationName = "yapp25thTeamTnT"
public static let destinations: Destinations = .iOS
public static let deploymentTarget: DeploymentTargets = .iOS("17.0")
}
83 changes: 67 additions & 16 deletions TnT/Tuist/ProjectDescriptionHelpers/Project/Project+Templates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,94 @@
@preconcurrency import ProjectDescription

public extension Project {
private static let appName = environmentName
private static let organizationName = environmentOrganizationName

private static let appName = Environment.appName
private static let organizationName = Environment.organizationName
static let customOption: Options = .options(
defaultKnownRegions: ["en", "ko"],
developmentRegion: "ko"
)

static var app: Project {
static func appProject(
dependencies: [TargetDependency] = []
) -> Project {
return Project(
name: appName,
organizationName: organizationName,
options: customOption,
settings: Configuration.defaultSettings(),
targets: .app,
targets: [
Target.appTarget(
dependencies: DependencyInformation.dependencies(of: appName)
)
],
schemes: .app
)
}

static func module(
static func dynamicFrameworkProject(
name: String,
options: Options = customOption,
resources: Bool
resources: Bool,
dependencies: [TargetDependency] = [],
packages: [Package] = []
) -> Project {
let debugScheme = Scheme.scheme(
schemeName: "\(name)Debug",
targetName: name,
configurationName: .debug
)

let releaseScheme = Scheme.scheme(
schemeName: "\(name)Release",
targetName: name,
configurationName: .release
)

return Project(
name: name,
options: customOption,
settings: Configuration.defaultSettings(),
targets: [
Target.dynamicLibraryTarget(
name: name,
resource: resources,
dependencies: DependencyInformation.dependencies(of: name)
)
],
schemes: [debugScheme, releaseScheme]
)
}

static func staticLibraryProejct(
name: String,
resource: Bool,
dependenceis: [TargetDependency] = []
) -> Project {
let debugScheme = Scheme.scheme(
schemeName: "\(name)Debug",
targetName: name,
configurationName: .debug
)

let releaseScheme = Scheme.scheme(
schemeName: "\(name)Release",
targetName: name,
configurationName: .release
)

return Project(
name: name,
organizationName: organizationName,
options: options,
options: customOption,
settings: Configuration.defaultSettings(),
targets: .targets(name: name, resources: resources),
schemes: [
.scheme(
schemeName: name,
targetName: name,
configurationName: .debug
targets: [
Target.staticLibraryTarget(
name: name,
resource: resource,
dependencies: DependencyInformation.dependencies(of: name)
)
]
],
schemes: [debugScheme, releaseScheme]
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

extension Array where Element == Scheme {
static var app: [Scheme] {
let name = environmentName
let name = Environment.appName
let deployTargets: [ConfigurationName] = [.debug, .release]

return deployTargets.map {
Expand Down
Loading