Skip to content
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
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ jobs:
install: true
cache: true

- name: Install SwiftLint
shell: bash
run: |
set -euo pipefail

brew list swiftlint >/dev/null 2>&1 || brew install swiftlint
swiftlint version

- name: Cache SwiftPM
uses: actions/cache@v5
with:
Expand Down Expand Up @@ -255,6 +263,14 @@ jobs:
install: true
cache: true

- name: Install SwiftLint
shell: bash
run: |
set -euo pipefail

brew list swiftlint >/dev/null 2>&1 || brew install swiftlint
swiftlint version

- name: Cache SwiftPM
uses: actions/cache@v5
with:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/testflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ jobs:
install: true
cache: true

- name: Install SwiftLint
shell: bash
run: |
set -euo pipefail

brew list swiftlint >/dev/null 2>&1 || brew install swiftlint
swiftlint version

- name: Generate Xcode workspace with Tuist
shell: bash
run: |
Expand Down
17 changes: 15 additions & 2 deletions Application/DevLogApp/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let project = Project(
disableBundleAccessors: true,
disableSynthesizedResourceAccessors: true
),
packages: DevLogPackages.lintOnlyPackages,
packages: DevLogPackages.defaultPackages,
settings: .devlogProject(versionXcconfigPath: "../Shared/Version.xcconfig"),
targets: [
.target(
Expand All @@ -24,6 +24,12 @@ let project = Project(
"Sources/Resource/Localizable.xcstrings",
],
entitlements: .file(path: "Sources/Resource/DevLog.entitlements"),
scripts: [
DevLogScripts.swiftLint(
sourcePath: "Sources",
configPath: "Sources/.swiftlint.yml"
),
],
dependencies: [
.project(target: "DevLogPresentation", path: "../DevLogPresentation"),
.project(target: "DevLogPersistence", path: "../DevLogPersistence"),
Expand All @@ -33,13 +39,13 @@ let project = Project(
.project(target: "DevLogCore", path: "../DevLogCore"),
.project(target: "DevLogWidgetCore", path: "../../Widget/DevLogWidgetCore"),
.project(target: "DevLogWidgetExtension", path: "../../Widget/DevLogWidgetExtension"),
DevLogPackages.swiftLintPlugin,
],
settings: .devlog(
versionXcconfigPath: "Sources/Resource/App.xcconfig",
base: [
"ASSETCATALOG_COMPILER_APPICON_NAME": "AppIcon",
"CODE_SIGN_STYLE": "Automatic",
"ENABLE_USER_SCRIPT_SANDBOXING": "NO",
"PRODUCT_MODULE_NAME": "DevLogApp",
],
debug: [
Expand All @@ -57,13 +63,20 @@ let project = Project(
bundleId: "opfic.DevLogAppTests",
infoPlist: .file(path: "../Shared/InfoPlists/UnitTests-Info.plist"),
sources: ["Tests/**/*.swift"],
scripts: [
DevLogScripts.swiftLint(
sourcePath: "Tests",
configPath: "Tests/.swiftlint.yml"
),
],
dependencies: [
.target(name: "DevLogApp"),
],
settings: .devlog(
base: [
"BUNDLE_LOADER": "$(TEST_HOST)",
"CODE_SIGN_STYLE": "Automatic",
"ENABLE_USER_SCRIPT_SANDBOXING": "NO",
"TEST_HOST": "$(BUILT_PRODUCTS_DIR)/DevLog.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/DevLog",
"TEST_TARGET_NAME": "DevLogApp",
]
Expand Down
2 changes: 1 addition & 1 deletion Application/DevLogCore/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ let project = Project.devlogFramework(
versionXcconfigPath: "../Shared/Version.xcconfig",
frameworkInfoPlistPath: "../Shared/InfoPlists/Framework-Info.plist",
testsInfoPlistPath: "../Shared/InfoPlists/UnitTests-Info.plist",
packages: DevLogPackages.lintOnlyPackages,
packages: DevLogPackages.defaultPackages,
hasTests: false
)
2 changes: 1 addition & 1 deletion Application/DevLogData/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let project = Project.devlogFramework(
versionXcconfigPath: "../Shared/Version.xcconfig",
frameworkInfoPlistPath: "../Shared/InfoPlists/Framework-Info.plist",
testsInfoPlistPath: "../Shared/InfoPlists/UnitTests-Info.plist",
packages: DevLogPackages.lintOnlyPackages,
packages: DevLogPackages.defaultPackages,
dependencies: [
.project(target: "DevLogDomain", path: "../DevLogDomain"),
.project(target: "DevLogCore", path: "../DevLogCore"),
Expand Down
2 changes: 1 addition & 1 deletion Application/DevLogDomain/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let project = Project.devlogFramework(
versionXcconfigPath: "../Shared/Version.xcconfig",
frameworkInfoPlistPath: "../Shared/InfoPlists/Framework-Info.plist",
testsInfoPlistPath: "../Shared/InfoPlists/UnitTests-Info.plist",
packages: DevLogPackages.lintOnlyPackages,
packages: DevLogPackages.defaultPackages,
dependencies: [
.project(target: "DevLogCore", path: "../DevLogCore"),
],
Expand Down
2 changes: 1 addition & 1 deletion Application/DevLogPersistence/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let project = Project.devlogFramework(
versionXcconfigPath: "../Shared/Version.xcconfig",
frameworkInfoPlistPath: "../Shared/InfoPlists/Framework-Info.plist",
testsInfoPlistPath: "../Shared/InfoPlists/UnitTests-Info.plist",
packages: DevLogPackages.lintOnlyPackages,
packages: DevLogPackages.defaultPackages,
dependencies: [
.project(target: "DevLogData", path: "../DevLogData"),
.project(target: "DevLogCore", path: "../DevLogCore"),
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ MVVM을 기반으로 하되, ViewModel 상태 관리에는 MVI 형태의 단방

```bash
brew install mise
brew install swiftlint
mise install
```

Expand Down
66 changes: 52 additions & 14 deletions Tuist/ProjectDescriptionHelpers/Project+Packages.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import ProjectDescription

public enum DevLogPackages {
public static let swiftLintPackage: Package = .package(
url: "https://github.com/realm/SwiftLint",
.upToNextMajor(from: "0.62.1")
)
public static let markdownUIPackage: Package = .package(
url: "https://github.com/gonzalezreal/swift-markdown-ui.git",
.upToNextMajor(from: "2.4.1")
Expand All @@ -13,6 +9,10 @@ public enum DevLogPackages {
url: "https://github.com/apple/swift-collections.git",
.upToNextMajor(from: "1.3.0")
)
public static let composableArchitecturePackage: Package = .package(
url: "https://github.com/pointfreeco/swift-composable-architecture",
.upToNextMajor(from: "1.25.5")
)
public static let firebasePackage: Package = .package(
url: "https://github.com/firebase/firebase-ios-sdk",
.upToNextMajor(from: "11.15.0")
Expand All @@ -26,12 +26,8 @@ public enum DevLogPackages {
.upToNextMajor(from: "1.1.0")
)

public static let swiftLintPlugin: TargetDependency = .package(
product: "SwiftLintBuildToolPlugin",
type: .plugin
)

public static let presentationPackageDependencies: [TargetDependency] = [
.package(product: "ComposableArchitecture"),
.package(product: "MarkdownUI"),
.package(product: "OrderedCollections"),
]
Expand All @@ -47,20 +43,62 @@ public enum DevLogPackages {
.package(product: "Nexa"),
]

public static let lintOnlyPackages: [Package] = [
swiftLintPackage,
]
public static let defaultPackages: [Package] = []

public static let presentationPackages: [Package] = [
swiftLintPackage,
composableArchitecturePackage,
markdownUIPackage,
swiftCollectionsPackage,
]

public static let infraPackages: [Package] = [
swiftLintPackage,
firebasePackage,
googleSignInPackage,
nexaPackage,
]
}

public enum DevLogScripts {
public static func swiftLint(
sourcePath: String,
configPath: String = "../../.swiftlint.yml"
) -> TargetScript {
TargetScript.pre(
script: """
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"

swiftLintPath="$(command -v swiftlint || true)"
if [ -z "$swiftLintPath" ]; then
echo "error: SwiftLint is not installed. Run 'brew install swiftlint'."
exit 1
fi

configPath="${SRCROOT}/\(configPath)"
sourcePathName="\(sourcePath)"
lintSourcePath="${SRCROOT}/${sourcePathName}"

if [ "$sourcePathName" != "." ]; then
"$swiftLintPath" lint --config "$configPath" "$lintSourcePath"
else
swiftFilePaths=()
while IFS= read -r -d '' swiftFilePath; do
swiftFilePaths+=("$swiftFilePath")
done < <(find "$lintSourcePath" -name "*.swift" -not -path "*/Derived/*" -not -name "Project.swift" -print0)

if [ ${#swiftFilePaths[@]} -lt 1 ]; then
exit 0
fi

"$swiftLintPath" lint --config "$configPath" "${swiftFilePaths[@]}"
fi
Comment thread
opficdev marked this conversation as resolved.
""",
name: "SwiftLint",
inputPaths: [
"$(SRCROOT)/\(configPath)",
"$(SRCROOT)/\(sourcePath)",
],
basedOnDependencyAnalysis: false,
shellPath: "/bin/bash"
)
}
}
24 changes: 21 additions & 3 deletions Tuist/ProjectDescriptionHelpers/Project+Templates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public extension Project {
versionXcconfigPath: Path,
frameworkInfoPlistPath: Path,
testsInfoPlistPath: Path,
packages: [Package] = DevLogPackages.lintOnlyPackages,
packages: [Package] = DevLogPackages.defaultPackages,
dependencies: [TargetDependency] = [],
hasTests: Bool
) -> Project {
Expand All @@ -19,8 +19,19 @@ public extension Project {
bundleId: bundleId,
infoPlist: .file(path: frameworkInfoPlistPath),
sources: ["Sources/**/*.swift"],
dependencies: dependencies + [DevLogPackages.swiftLintPlugin],
settings: .devlog(versionXcconfigPath: versionXcconfigPath)
scripts: [
DevLogScripts.swiftLint(
sourcePath: "Sources",
configPath: "Sources/.swiftlint.yml"
),
],
dependencies: dependencies,
settings: .devlog(
versionXcconfigPath: versionXcconfigPath,
base: [
"ENABLE_USER_SCRIPT_SANDBOXING": "NO",
]
)
),
]

Expand All @@ -33,11 +44,18 @@ public extension Project {
bundleId: "\(bundleId)Tests",
infoPlist: .file(path: testsInfoPlistPath),
sources: ["Tests/**/*.swift"],
scripts: [
DevLogScripts.swiftLint(
sourcePath: "Tests",
configPath: "Tests/.swiftlint.yml"
),
],
dependencies: [
.target(name: name),
],
settings: .devlog(
base: [
"ENABLE_USER_SCRIPT_SANDBOXING": "NO",
"TEST_TARGET_NAME": SettingValue(stringLiteral: name),
]
)
Expand Down
2 changes: 1 addition & 1 deletion Widget/DevLogWidgetCore/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let project = Project.devlogFramework(
versionXcconfigPath: "../../Application/Shared/Version.xcconfig",
frameworkInfoPlistPath: "../../Application/Shared/InfoPlists/Framework-Info.plist",
testsInfoPlistPath: "../../Application/Shared/InfoPlists/UnitTests-Info.plist",
packages: DevLogPackages.lintOnlyPackages,
packages: DevLogPackages.defaultPackages,
dependencies: [
.project(target: "DevLogCore", path: "../../Application/DevLogCore"),
],
Expand Down
4 changes: 4 additions & 0 deletions Widget/DevLogWidgetExtension/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ let project = Project(
"Resource/Localizable.xcstrings",
],
entitlements: .file(path: "Resource/DevLogWidget.entitlements"),
scripts: [
DevLogScripts.swiftLint(sourcePath: "."),
],
dependencies: [
.project(target: "DevLogWidgetCore", path: "../DevLogWidgetCore"),
],
settings: .devlog(
versionXcconfigPath: "../../Application/Shared/Version.xcconfig",
base: [
"CODE_SIGN_STYLE": "Automatic",
"ENABLE_USER_SCRIPT_SANDBOXING": "NO",
]
)
),
Expand Down