Skip to content

Commit

Permalink
πŸ”— :: (#48) XCConfig μ„€μ •
Browse files Browse the repository at this point in the history
πŸ”— :: (#48) XCConfig μ„€μ •
  • Loading branch information
HongSJae authored Dec 21, 2023
2 parents e5db572 + 5033c78 commit b1d1528
Show file tree
Hide file tree
Showing 50 changed files with 669 additions and 160 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ Derived/

### Tuist managed dependencies ###
Tuist/Dependencies

XCConfig/
3 changes: 3 additions & 0 deletions Plugins/ConfigurationPlugin/Plugin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ProjectDescription

let plugin = Plugin(name: "ConfigurationPlugin")
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import ProjectDescription

public extension ConfigurationName {
static var dev: ConfigurationName { configuration(ProjectDeployTarget.dev.rawValue) }
static var stage: ConfigurationName { configuration(ProjectDeployTarget.stage.rawValue) }
static var prod: ConfigurationName { configuration(ProjectDeployTarget.prod.rawValue) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import ProjectDescription

public extension ProjectDescription.Path {
static func relativeToXCConfig(type: ProjectDeployTarget, name: String) -> Self {
.relativeToRoot("XCConfig/\(name)/\(type.rawValue).xcconfig")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Foundation
import ProjectDescription

public enum ProjectDeployTarget: String {
case dev = "DEV"
case stage = "STAGE"
case prod = "PROD"

public var configurationName: ConfigurationName {
ConfigurationName.configuration(self.rawValue)
}
}
3 changes: 0 additions & 3 deletions Plugins/EnviromentPlugin/Plugin.swift

This file was deleted.

This file was deleted.

3 changes: 3 additions & 0 deletions Plugins/EnvironmentPlugin/Plugin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ProjectDescription

let plugin = Plugin(name: "EnvironmentPlugin")
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import ProjectDescription

public struct ProjectEnvironment {
public let appName: String
public let targetName: String
public let targetTestName: String
public let organizationName: String
public let deploymentTarget: DeploymentTarget
public let platform: Platform
public let baseSetting: SettingsDictionary
}

public let env = ProjectEnvironment(
appName: "JOBIS-DSM-iOS-v2",
targetName: "JOBIS-DSM-iOS-v2",
targetTestName: "DSM-JOBISTests",
organizationName: "com.team.return",
deploymentTarget: .iOS(targetVersion: "15.0", devices: [.iphone, .ipad]),
platform: .iOS,
baseSetting: [:]
)
10 changes: 0 additions & 10 deletions Projects/App/JOBIS-DSM-iOS-v2Debug.entitlements

This file was deleted.

107 changes: 97 additions & 10 deletions Projects/App/Project.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,101 @@
import ProjectDescription
import ProjectDescriptionHelpers
import ProjectDescription
import DependencyPlugin
import EnvironmentPlugin
import ConfigurationPlugin
import Foundation

let isCI: Bool = (ProcessInfo.processInfo.environment["TUIST_CI"] ?? "0") == "1"

let configurations: [Configuration] = [
.debug(name: .dev, xcconfig: .relativeToXCConfig(type: .dev, name: env.targetName)),
.debug(name: .stage, xcconfig: .relativeToXCConfig(type: .stage, name: env.targetName)),
.release(name: .prod, xcconfig: .relativeToXCConfig(type: .prod, name: env.targetName))
]

let settings: Settings = .settings(
base: env.baseSetting,
configurations: configurations,
defaultSettings: .recommended
)

let scripts: [TargetScript] = isCI ? [] : [.swiftLint]

let targets: [Target] = [
.init(
name: env.targetName,
platform: env.platform,
product: .app,
bundleId: "$(APP_BUNDLE_ID)",
deploymentTarget: env.deploymentTarget,
infoPlist: .file(path: "Support/Info.plist"),
sources: .sources,
resources: .resources,
entitlements: "Support/\(env.appName).entitlements",
scripts: scripts,
dependencies: [
.Projects.flow
],
settings: .settings(base: env.baseSetting)
),
.init(
name: env.targetTestName,
platform: .iOS,
product: .unitTests,
bundleId: "\(env.organizationName).\(env.targetName)Tests",
deploymentTarget: env.deploymentTarget,
infoPlist: .default,
sources: .unitTests,
dependencies: [
.target(name: env.targetName)
]
)
]

let schemes: [Scheme] = [
.init(
name: "\(env.targetName)-DEV",
shared: true,
buildAction: .buildAction(targets: ["\(env.targetName)"]),
testAction: TestAction.targets(
["\(env.targetTestName)"],
configuration: .dev,
options: TestActionOptions.options(
coverage: true,
codeCoverageTargets: ["\(env.targetName)"]
)
),
runAction: .runAction(configuration: .dev),
archiveAction: .archiveAction(configuration: .dev),
profileAction: .profileAction(configuration: .dev),
analyzeAction: .analyzeAction(configuration: .dev)
),
.init(
name: "\(env.targetName)-PROD",
shared: true,
buildAction: BuildAction(targets: ["\(env.targetName)"]),
testAction: nil,
runAction: .runAction(configuration: .prod),
archiveAction: .archiveAction(configuration: .prod),
profileAction: .profileAction(configuration: .prod),
analyzeAction: .analyzeAction(configuration: .prod)
),
.init(
name: "\(env.targetName)-STAGE",
shared: true,
buildAction: BuildAction(targets: ["\(env.targetName)"]),
testAction: nil,
runAction: .runAction(configuration: .stage),
archiveAction: .archiveAction(configuration: .stage),
profileAction: .profileAction(configuration: .stage),
analyzeAction: .analyzeAction(configuration: .stage)
)
]

let project = Project.makeModule(
name: "JOBIS-DSM-iOS-v2",
platform: .iOS,
product: .app,
dependencies: [
.Projects.flow
],
resources: ["Resources/**"],
infoPlist: .file(path: "Support/Info.plist")
let project = Project(
name: env.targetName,
organizationName: env.organizationName,
settings: settings,
targets: targets,
schemes: schemes
)
10 changes: 7 additions & 3 deletions Projects/App/Support/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
<dict>
<key>AppIdentifierPrefix</key>
<string>$(AppIdentifierPrefix)</string>
<key>BASE_URL</key>
<string>https://dev-server.team-return.com</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>API_BASE_URL</key>
<string>$(API_BASE_URL)</string>
<key>S3_BASE_URL</key>
<string>$(S3_BASE_URL)</string>
<key>CFBundleDisplayName</key>
<string>$(BUNDLE_DISPLAY_NAME)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand All @@ -27,7 +31,7 @@
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
Expand Down
17 changes: 17 additions & 0 deletions Projects/App/Tests/TargetTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import XCTest

final class TargetTests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() throws {
XCTAssertEqual(1, 1)
}

}
3 changes: 2 additions & 1 deletion Projects/Core/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import DependencyPlugin

let project = Project.makeModule(
name: "Core",
product: .staticFramework,
product: .framework,
targets: [.unitTest],
dependencies: [
.Modules.thirdPartyLib
]
Expand Down
17 changes: 17 additions & 0 deletions Projects/Core/Tests/TargetTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import XCTest

final class TargetTests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() throws {
XCTAssertEqual(1, 1)
}

}
1 change: 1 addition & 0 deletions Projects/Data/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DependencyPlugin
let project = Project.makeModule(
name: "Data",
product: .staticFramework,
targets: [.unitTest],
dependencies: [
.Projects.domain,
.Modules.appNetwork
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RemoteBaseDataSource<API: JobisAPI> {
#if DEBUG
self.provider = MoyaProvider<API>(plugins: [JwtPlugin(keychain: keychain), MoyaLogginPlugin()])
#else
self.provider = MoyaProvider<API>(plugins: [JwtPlugin()])
self.provider = MoyaProvider<API>(plugins: [JwtPlugin(keychain: keychain)])
#endif
}

Expand Down
17 changes: 17 additions & 0 deletions Projects/Data/Tests/TargetTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import XCTest

final class TargetTests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() throws {
XCTAssertEqual(1, 1)
}

}
1 change: 1 addition & 0 deletions Projects/Domain/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DependencyPlugin
let project = Project.makeModule(
name: "Domain",
product: .staticFramework,
targets: [.unitTest],
dependencies: [
.Projects.core
]
Expand Down
17 changes: 17 additions & 0 deletions Projects/Domain/Tests/TargetTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import XCTest

final class TargetTests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() throws {
XCTAssertEqual(1, 1)
}

}
3 changes: 2 additions & 1 deletion Projects/Flow/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import DependencyPlugin

let project = Project.makeModule(
name: "Flow",
product: .staticFramework,
product: .staticLibrary,
targets: [.unitTest],
dependencies: [
.Projects.data,
.Projects.presentation
Expand Down
17 changes: 17 additions & 0 deletions Projects/Flow/Tests/TargetTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import XCTest

final class TargetTests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() throws {
XCTAssertEqual(1, 1)
}

}
3 changes: 2 additions & 1 deletion Projects/Modules/AppNetwork/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import DependencyPlugin

let project = Project.makeModule(
name: "AppNetwork",
product: .staticFramework,
product: .framework,
targets: [.unitTest],
dependencies: [
.Projects.core
]
Expand Down
2 changes: 1 addition & 1 deletion Projects/Modules/AppNetwork/Sources/JobisAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public protocol JobisAPI: TargetType, JwtAuthorizable {
public extension JobisAPI {
var baseURL: URL {
URL(
string: Bundle.main.object(forInfoDictionaryKey: "BASE_URL") as? String ?? ""
string: Bundle.main.object(forInfoDictionaryKey: "API_BASE_URL") as? String ?? ""
) ?? URL(string: "https://www.google.com")!
}

Expand Down
Loading

0 comments on commit b1d1528

Please sign in to comment.