Skip to content

Commit 5ee94f4

Browse files
authored
[#510] TCA 라이브러리 의존성을 추가한다 (#540)
* chore: SwiftLint 실행 방식 정리 * chore: TCA 의존성 추가 * chore: 테스트 SwiftLint 설정 반영 * chore: SwiftLint 파일 실행 방식 개선
1 parent 2538b4e commit 5ee94f4

12 files changed

Lines changed: 122 additions & 24 deletions

File tree

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ jobs:
5858
install: true
5959
cache: true
6060

61+
- name: Install SwiftLint
62+
shell: bash
63+
run: |
64+
set -euo pipefail
65+
66+
brew list swiftlint >/dev/null 2>&1 || brew install swiftlint
67+
swiftlint version
68+
6169
- name: Cache SwiftPM
6270
uses: actions/cache@v5
6371
with:
@@ -255,6 +263,14 @@ jobs:
255263
install: true
256264
cache: true
257265

266+
- name: Install SwiftLint
267+
shell: bash
268+
run: |
269+
set -euo pipefail
270+
271+
brew list swiftlint >/dev/null 2>&1 || brew install swiftlint
272+
swiftlint version
273+
258274
- name: Cache SwiftPM
259275
uses: actions/cache@v5
260276
with:

.github/workflows/testflight.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ jobs:
9090
install: true
9191
cache: true
9292

93+
- name: Install SwiftLint
94+
shell: bash
95+
run: |
96+
set -euo pipefail
97+
98+
brew list swiftlint >/dev/null 2>&1 || brew install swiftlint
99+
swiftlint version
100+
93101
- name: Generate Xcode workspace with Tuist
94102
shell: bash
95103
run: |

Application/DevLogApp/Project.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let project = Project(
77
disableBundleAccessors: true,
88
disableSynthesizedResourceAccessors: true
99
),
10-
packages: DevLogPackages.lintOnlyPackages,
10+
packages: DevLogPackages.defaultPackages,
1111
settings: .devlogProject(versionXcconfigPath: "../Shared/Version.xcconfig"),
1212
targets: [
1313
.target(
@@ -24,6 +24,12 @@ let project = Project(
2424
"Sources/Resource/Localizable.xcstrings",
2525
],
2626
entitlements: .file(path: "Sources/Resource/DevLog.entitlements"),
27+
scripts: [
28+
DevLogScripts.swiftLint(
29+
sourcePath: "Sources",
30+
configPath: "Sources/.swiftlint.yml"
31+
),
32+
],
2733
dependencies: [
2834
.project(target: "DevLogPresentation", path: "../DevLogPresentation"),
2935
.project(target: "DevLogPersistence", path: "../DevLogPersistence"),
@@ -33,13 +39,13 @@ let project = Project(
3339
.project(target: "DevLogCore", path: "../DevLogCore"),
3440
.project(target: "DevLogWidgetCore", path: "../../Widget/DevLogWidgetCore"),
3541
.project(target: "DevLogWidgetExtension", path: "../../Widget/DevLogWidgetExtension"),
36-
DevLogPackages.swiftLintPlugin,
3742
],
3843
settings: .devlog(
3944
versionXcconfigPath: "Sources/Resource/App.xcconfig",
4045
base: [
4146
"ASSETCATALOG_COMPILER_APPICON_NAME": "AppIcon",
4247
"CODE_SIGN_STYLE": "Automatic",
48+
"ENABLE_USER_SCRIPT_SANDBOXING": "NO",
4349
"PRODUCT_MODULE_NAME": "DevLogApp",
4450
],
4551
debug: [
@@ -57,13 +63,20 @@ let project = Project(
5763
bundleId: "opfic.DevLogAppTests",
5864
infoPlist: .file(path: "../Shared/InfoPlists/UnitTests-Info.plist"),
5965
sources: ["Tests/**/*.swift"],
66+
scripts: [
67+
DevLogScripts.swiftLint(
68+
sourcePath: "Tests",
69+
configPath: "Tests/.swiftlint.yml"
70+
),
71+
],
6072
dependencies: [
6173
.target(name: "DevLogApp"),
6274
],
6375
settings: .devlog(
6476
base: [
6577
"BUNDLE_LOADER": "$(TEST_HOST)",
6678
"CODE_SIGN_STYLE": "Automatic",
79+
"ENABLE_USER_SCRIPT_SANDBOXING": "NO",
6780
"TEST_HOST": "$(BUILT_PRODUCTS_DIR)/DevLog.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/DevLog",
6881
"TEST_TARGET_NAME": "DevLogApp",
6982
]

Application/DevLogCore/Project.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ let project = Project.devlogFramework(
77
versionXcconfigPath: "../Shared/Version.xcconfig",
88
frameworkInfoPlistPath: "../Shared/InfoPlists/Framework-Info.plist",
99
testsInfoPlistPath: "../Shared/InfoPlists/UnitTests-Info.plist",
10-
packages: DevLogPackages.lintOnlyPackages,
10+
packages: DevLogPackages.defaultPackages,
1111
hasTests: false
1212
)

Application/DevLogData/Project.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let project = Project.devlogFramework(
77
versionXcconfigPath: "../Shared/Version.xcconfig",
88
frameworkInfoPlistPath: "../Shared/InfoPlists/Framework-Info.plist",
99
testsInfoPlistPath: "../Shared/InfoPlists/UnitTests-Info.plist",
10-
packages: DevLogPackages.lintOnlyPackages,
10+
packages: DevLogPackages.defaultPackages,
1111
dependencies: [
1212
.project(target: "DevLogDomain", path: "../DevLogDomain"),
1313
.project(target: "DevLogCore", path: "../DevLogCore"),

Application/DevLogDomain/Project.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let project = Project.devlogFramework(
77
versionXcconfigPath: "../Shared/Version.xcconfig",
88
frameworkInfoPlistPath: "../Shared/InfoPlists/Framework-Info.plist",
99
testsInfoPlistPath: "../Shared/InfoPlists/UnitTests-Info.plist",
10-
packages: DevLogPackages.lintOnlyPackages,
10+
packages: DevLogPackages.defaultPackages,
1111
dependencies: [
1212
.project(target: "DevLogCore", path: "../DevLogCore"),
1313
],

Application/DevLogPersistence/Project.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let project = Project.devlogFramework(
77
versionXcconfigPath: "../Shared/Version.xcconfig",
88
frameworkInfoPlistPath: "../Shared/InfoPlists/Framework-Info.plist",
99
testsInfoPlistPath: "../Shared/InfoPlists/UnitTests-Info.plist",
10-
packages: DevLogPackages.lintOnlyPackages,
10+
packages: DevLogPackages.defaultPackages,
1111
dependencies: [
1212
.project(target: "DevLogData", path: "../DevLogData"),
1313
.project(target: "DevLogCore", path: "../DevLogCore"),

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ MVVM을 기반으로 하되, ViewModel 상태 관리에는 MVI 형태의 단방
176176

177177
```bash
178178
brew install mise
179+
brew install swiftlint
179180
mise install
180181
```
181182

Tuist/ProjectDescriptionHelpers/Project+Packages.swift

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import ProjectDescription
22

33
public enum DevLogPackages {
4-
public static let swiftLintPackage: Package = .package(
5-
url: "https://github.com/realm/SwiftLint",
6-
.upToNextMajor(from: "0.62.1")
7-
)
84
public static let markdownUIPackage: Package = .package(
95
url: "https://github.com/gonzalezreal/swift-markdown-ui.git",
106
.upToNextMajor(from: "2.4.1")
@@ -13,6 +9,10 @@ public enum DevLogPackages {
139
url: "https://github.com/apple/swift-collections.git",
1410
.upToNextMajor(from: "1.3.0")
1511
)
12+
public static let composableArchitecturePackage: Package = .package(
13+
url: "https://github.com/pointfreeco/swift-composable-architecture",
14+
.upToNextMajor(from: "1.25.5")
15+
)
1616
public static let firebasePackage: Package = .package(
1717
url: "https://github.com/firebase/firebase-ios-sdk",
1818
.upToNextMajor(from: "11.15.0")
@@ -26,12 +26,8 @@ public enum DevLogPackages {
2626
.upToNextMajor(from: "1.1.0")
2727
)
2828

29-
public static let swiftLintPlugin: TargetDependency = .package(
30-
product: "SwiftLintBuildToolPlugin",
31-
type: .plugin
32-
)
33-
3429
public static let presentationPackageDependencies: [TargetDependency] = [
30+
.package(product: "ComposableArchitecture"),
3531
.package(product: "MarkdownUI"),
3632
.package(product: "OrderedCollections"),
3733
]
@@ -47,20 +43,62 @@ public enum DevLogPackages {
4743
.package(product: "Nexa"),
4844
]
4945

50-
public static let lintOnlyPackages: [Package] = [
51-
swiftLintPackage,
52-
]
46+
public static let defaultPackages: [Package] = []
5347

5448
public static let presentationPackages: [Package] = [
55-
swiftLintPackage,
49+
composableArchitecturePackage,
5650
markdownUIPackage,
5751
swiftCollectionsPackage,
5852
]
5953

6054
public static let infraPackages: [Package] = [
61-
swiftLintPackage,
6255
firebasePackage,
6356
googleSignInPackage,
6457
nexaPackage,
6558
]
6659
}
60+
61+
public enum DevLogScripts {
62+
public static func swiftLint(
63+
sourcePath: String,
64+
configPath: String = "../../.swiftlint.yml"
65+
) -> TargetScript {
66+
TargetScript.pre(
67+
script: """
68+
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
69+
70+
swiftLintPath="$(command -v swiftlint || true)"
71+
if [ -z "$swiftLintPath" ]; then
72+
echo "error: SwiftLint is not installed. Run 'brew install swiftlint'."
73+
exit 1
74+
fi
75+
76+
configPath="${SRCROOT}/\(configPath)"
77+
sourcePathName="\(sourcePath)"
78+
lintSourcePath="${SRCROOT}/${sourcePathName}"
79+
80+
if [ "$sourcePathName" != "." ]; then
81+
"$swiftLintPath" lint --config "$configPath" "$lintSourcePath"
82+
else
83+
swiftFilePaths=()
84+
while IFS= read -r -d '' swiftFilePath; do
85+
swiftFilePaths+=("$swiftFilePath")
86+
done < <(find "$lintSourcePath" -name "*.swift" -not -path "*/Derived/*" -not -name "Project.swift" -print0)
87+
88+
if [ ${#swiftFilePaths[@]} -lt 1 ]; then
89+
exit 0
90+
fi
91+
92+
"$swiftLintPath" lint --config "$configPath" "${swiftFilePaths[@]}"
93+
fi
94+
""",
95+
name: "SwiftLint",
96+
inputPaths: [
97+
"$(SRCROOT)/\(configPath)",
98+
"$(SRCROOT)/\(sourcePath)",
99+
],
100+
basedOnDependencyAnalysis: false,
101+
shellPath: "/bin/bash"
102+
)
103+
}
104+
}

Tuist/ProjectDescriptionHelpers/Project+Templates.swift

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public extension Project {
77
versionXcconfigPath: Path,
88
frameworkInfoPlistPath: Path,
99
testsInfoPlistPath: Path,
10-
packages: [Package] = DevLogPackages.lintOnlyPackages,
10+
packages: [Package] = DevLogPackages.defaultPackages,
1111
dependencies: [TargetDependency] = [],
1212
hasTests: Bool
1313
) -> Project {
@@ -19,8 +19,19 @@ public extension Project {
1919
bundleId: bundleId,
2020
infoPlist: .file(path: frameworkInfoPlistPath),
2121
sources: ["Sources/**/*.swift"],
22-
dependencies: dependencies + [DevLogPackages.swiftLintPlugin],
23-
settings: .devlog(versionXcconfigPath: versionXcconfigPath)
22+
scripts: [
23+
DevLogScripts.swiftLint(
24+
sourcePath: "Sources",
25+
configPath: "Sources/.swiftlint.yml"
26+
),
27+
],
28+
dependencies: dependencies,
29+
settings: .devlog(
30+
versionXcconfigPath: versionXcconfigPath,
31+
base: [
32+
"ENABLE_USER_SCRIPT_SANDBOXING": "NO",
33+
]
34+
)
2435
),
2536
]
2637

@@ -33,11 +44,18 @@ public extension Project {
3344
bundleId: "\(bundleId)Tests",
3445
infoPlist: .file(path: testsInfoPlistPath),
3546
sources: ["Tests/**/*.swift"],
47+
scripts: [
48+
DevLogScripts.swiftLint(
49+
sourcePath: "Tests",
50+
configPath: "Tests/.swiftlint.yml"
51+
),
52+
],
3653
dependencies: [
3754
.target(name: name),
3855
],
3956
settings: .devlog(
4057
base: [
58+
"ENABLE_USER_SCRIPT_SANDBOXING": "NO",
4159
"TEST_TARGET_NAME": SettingValue(stringLiteral: name),
4260
]
4361
)

0 commit comments

Comments
 (0)