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

[GWL-80] 서버 URL을 XCConfig에 설정 #107

Merged
merged 8 commits into from
Nov 23, 2023
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 .github/workflows/iOS_CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ jobs:
working-directory: ${{env.working-directory}}

- name: Run Tuist Test
run: make test
run: make ci
working-directory: ${{env.working-directory}}
4 changes: 4 additions & 0 deletions iOS/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,7 @@ Derived/

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

### XCConfig ###

*.xcconfig
4 changes: 4 additions & 0 deletions iOS/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ demo:
@./Scripts/create_module.sh Demo
tuist edit

ci:
tuist clean
tuist fetch
TUIST_ROOT_DIR=${PWD} TUIST_CI=TRUE tuist test

test:
tuist clean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ public extension Path {
static func relativeToShared(_ path: String) -> Path {
.relativeToRoot("Projects/Shared/\(path)")
}

static func relativeToXCConfig(_ path: String = "Shared") -> Path {
.relativeToRoot("XCConfig/\(path).xcconfig")
}
}
7 changes: 7 additions & 0 deletions iOS/Projects/Core/Network/Sources/TNEndPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ public protocol TNEndPoint {
var headers: TNHeaders { get }
}

public extension TNEndPoint {
var baseURL: String {
// request를 생성할 때 빈 문자열이면 invalidURL Error로 자연스레 들어갑니다.
return Bundle.main.infoDictionary?["BaseURL"] as? String ?? ""
}
}

public extension TNEndPoint {
func request() throws -> URLRequest {
guard let targetURL = URL(string: baseURL)?.appending(path: path).appending(query: query)
Expand Down
10 changes: 0 additions & 10 deletions iOS/Projects/Core/Network/Sources/Trinet.swift

This file was deleted.

7 changes: 5 additions & 2 deletions iOS/Tuist/ProjectDescriptionHelpers/Project+Templates.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import EnvironmentPlugin
import ProjectDescription
import Foundation

private let isCI = ProcessInfo.processInfo.environment["TUIST_CI"] != nil

public extension Project {
static func makeModule(
Expand All @@ -11,8 +14,8 @@ public extension Project {
let settings: Settings = .settings(
base: ["ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS": "YES"],
configurations: [
.debug(name: .debug),
.release(name: .release),
.debug(name: .debug, xcconfig: isCI ? nil : .relativeToXCConfig()),
.release(name: .release, xcconfig: isCI ? nil : .relativeToXCConfig()),
]
)

Expand Down
23 changes: 16 additions & 7 deletions iOS/Tuist/ProjectDescriptionHelpers/Target+Templates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public extension [Target] {
infoPlist: [String: Plist.Value] = [:]
) -> [Target] {

var defaultInfoPlist: [String: Plist.Value] = [
let mergedInfoPlist: [String: Plist.Value] = [
"BaseURL": "$(BASE_URL)",
"UILaunchStoryboardName": "LaunchScreen",
"UIApplicationSceneManifest": [
"UIApplicationSupportsMultipleScenes": false,
Expand All @@ -45,9 +46,7 @@ public extension [Target] {
],
],
],
]

defaultInfoPlist.merge(infoPlist) { _, new in
].merging(infoPlist) { _, new in
new
}

Expand All @@ -58,7 +57,7 @@ public extension [Target] {
product: .app,
bundleId: "\(ProjectEnvironment.default.prefixBundleID).\(name.lowercased())",
deploymentTarget: ProjectEnvironment.default.deploymentTarget,
infoPlist: .extendingDefault(with: defaultInfoPlist),
infoPlist: .extendingDefault(with: mergedInfoPlist),
sources: "Sources/**",
resources: "Resources/**",
scripts: [.swiftFormat, .swiftLint],
Expand Down Expand Up @@ -113,6 +112,11 @@ public extension [Target] {
infoPlist: [String: Plist.Value] = [:],
resources: ResourceFileElements? = nil
) -> [Target] {

let mergedInfoPlist: [String: Plist.Value] = ["BaseURL": "$(BASE_URL)"].merging(infoPlist) { _, new in
new
}

// 에셋 리소스를 코드로 자동완성 해주는 옵션 활성화
let settings: Settings = .settings(
base: ["ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS": "YES"],
Expand All @@ -129,7 +133,7 @@ public extension [Target] {
product: .framework,
bundleId: "\(ProjectEnvironment.default.prefixBundleID).\(feature.targetName)Feature",
deploymentTarget: ProjectEnvironment.default.deploymentTarget,
infoPlist: .extendingDefault(with: infoPlist),
infoPlist: .extendingDefault(with: mergedInfoPlist),
sources: "Sources/**",
resources: resources,
scripts: [.swiftFormat, .swiftLint],
Expand Down Expand Up @@ -189,14 +193,19 @@ public extension [Target] {
resources: ResourceFileElements? = nil,
settings: Settings? = nil
) -> [Target] {

let mergedInfoPlist: [String: Plist.Value] = ["BaseURL": "$(BASE_URL)"].merging(infoPlist) { _, new in
new
}

var targets: [Target] = [
Target(
name: "\(name)",
platform: .iOS,
product: product,
bundleId: "\(ProjectEnvironment.default.prefixBundleID).\(name)",
deploymentTarget: ProjectEnvironment.default.deploymentTarget,
infoPlist: .extendingDefault(with: infoPlist),
infoPlist: .extendingDefault(with: mergedInfoPlist),
sources: "Sources/**",
resources: resources,
scripts: [.swiftFormat, .swiftLint],
Expand Down
Loading