Skip to content

Commit

Permalink
[GWL-3] Tuist 프로젝트 세팅 (#18)
Browse files Browse the repository at this point in the history
* build: Tuist를 통한 WeTri App Project 생성

* build: SwiftLint, SwiftFormat 적용

---------

Co-authored-by: JongPyoAhn <[email protected]>
  • Loading branch information
WhiteHyun and JongPyoAhn authored Nov 13, 2023
1 parent 16c657d commit ffafffe
Show file tree
Hide file tree
Showing 16 changed files with 392 additions and 1 deletion.
8 changes: 7 additions & 1 deletion iOS/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,17 @@ xcuserdata

### Xcode Patch ###
*.xcodeproj/*
*.xcworkspace
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcodeproj/project.xcworkspace/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno
**/xcshareddata/WorkspaceSettings.xcsettings

# End of https://www.toptal.com/developers/gitignore/api/swiftpackagemanager,swift,xcode
### Tuist derived files ###
graph.dot
Derived/

### Tuist managed dependencies ###
Tuist/Dependencies
22 changes: 22 additions & 0 deletions iOS/.swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--swiftversion 5.9

# format options

--indent 2
--selfrequired
--importgrouping alpha
--enable acronyms
--acronyms "URL, ID, UUID"
--enable blankLineAfterImports
--enable blankLinesAroundMark
--enable blockComments
--enable docComments
--enable isEmpty
--enable markTypes
--enable sortedSwitchCases
--enable wrapEnumCases
--enable wrapSwitchCases

--disable wrapMultilineStatementBraces
--disable andOperator
--disable redundantReturn
62 changes: 62 additions & 0 deletions iOS/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
only_rules:
- colon
- fatal_error_message
- implicitly_unwrapped_optional
- legacy_cggeometry_functions
- legacy_constant
- legacy_constructor
- legacy_nsgeometry_functions
- operator_usage_whitespace
- return_arrow_whitespace
- trailing_newline
- unused_optional_binding
- vertical_whitespace
- void_return
- unowned_variable_capture
- custom_rules

excluded:
- Carthage
- Pods
- .build

colon:
apply_to_dictionaries: false

indentation: 2

custom_rules:
no_objcMembers:
name: "@objcMembers"
regex: "@objcMembers"
message: "Explicitly use @objc on each member you want to expose to Objective-C"
severity: error
no_direct_standard_out_logs:
name: "Writing log messages directly to standard out is disallowed"
regex: "(\\bprint|\\bdebugPrint|\\bdump|Swift\\.print|Swift\\.debugPrint|Swift\\.dump)\\s*\\("
match_kinds:
- identifier
message: "Don't commit `print(…)`, `debugPrint(…)`, or `dump(…)` as they write to standard out in release. Either log to a dedicated logging system or silence this warning in debug-only scenarios explicitly using `// swiftlint:disable:next no_direct_standard_out_logs`"
severity: error
no_file_literal:
name: "#file is disallowed"
regex: "(\\b#file\\b)"
match_kinds:
- identifier
message: "Instead of #file, use #fileID"
severity: error
no_filepath_literal:
name: "#filePath is disallowed"
regex: "(\\b#filePath\\b)"
match_kinds:
- identifier
message: "Instead of #filePath, use #fileID."
severity: error
no_unchecked_sendable:
name: "`@unchecked Sendable` is discouraged."
regex: "@unchecked Sendable"
match_kinds:
- attribute.builtin
- typeidentifier
message: "Instead of using `@unchecked Sendable`, consider a safe alternative like a standard `Sendable` conformance or using `@preconcurrency import`. If you really must use `@unchecked Sendable`, you can add a `// swiftlint:disable:next no_unchecked_sendable` annotation with an explanation for how we know the type is thread-safe, and why we have to use @unchecked Sendable instead of Sendable. More explanation and suggested safe alternatives are available at https://github.com/airbnb/swift#unchecked-sendable."
severity: error
15 changes: 15 additions & 0 deletions iOS/Plugins/IOS/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// swift-tools-version: 5.8

import PackageDescription

let package = Package(
name: "MyPlugin",
products: [
.executable(name: "tuist-my-cli", targets: ["tuist-my-cli"]),
],
targets: [
.executableTarget(
name: "tuist-my-cli"
),
]
)
3 changes: 3 additions & 0 deletions iOS/Plugins/IOS/Plugin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ProjectDescription

let plugin = Plugin(name: "MyPlugin")
9 changes: 9 additions & 0 deletions iOS/Plugins/IOS/ProjectDescriptionHelpers/LocalHelper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Foundation

public struct LocalHelper {
let name: String

public init(name: String) {
self.name = name
}
}
1 change: 1 addition & 0 deletions iOS/Plugins/IOS/Sources/tuist-my-cli/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("Hello, from your Tuist Task")
31 changes: 31 additions & 0 deletions iOS/Projects/App/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Project.swift
// ProjectDescriptionHelpers
//
// Created by 홍승현 on 11/10/23.
//

import ProjectDescription
import ProjectDescriptionHelpers

let project = Project.makeModule(
name: "WeTri",
product: .app,
resources: ["Resources/**"],
infoPlist: .extendingDefault(
with: [
"UILaunchStoryboardName": "LaunchScreen",
"UIApplicationSceneManifest": [
"UIApplicationSupportsMultipleScenes": false,
"UISceneConfigurations": [
"UIWindowSceneSessionRoleApplication": [
[
"UISceneConfigurationName": "Default Configuration",
"UISceneDelegateClassName": "$(PRODUCT_MODULE_NAME).SceneDelegate",
],
],
],
],
]
)
)
25 changes: 25 additions & 0 deletions iOS/Projects/App/Resources/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
21 changes: 21 additions & 0 deletions iOS/Projects/App/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import UIKit

@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil
)
-> Bool {
return true
}

func application(
_: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options _: UIScene.ConnectionOptions
)
-> UISceneConfiguration {
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
}
20 changes: 20 additions & 0 deletions iOS/Projects/App/Sources/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// SceneDelegate.swift
// WeTri
//
// Created by 홍승현 on 11/10/23.
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved.
//

import UIKit

final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?

func scene(_ scene: UIScene, willConnectTo _: UISceneSession, options _: UIScene.ConnectionOptions) {
guard let windowScene = scene as? UIWindowScene else { return }
window = UIWindow(windowScene: windowScene)
window?.rootViewController = ViewController()
window?.makeKeyAndVisible()
}
}
17 changes: 17 additions & 0 deletions iOS/Projects/App/Sources/ViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// ViewController.swift
// WeTri
//
// Created by 홍승현 on 11/10/23.
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved.
//

import UIKit

final class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

view.backgroundColor = .systemBackground
}
}
3 changes: 3 additions & 0 deletions iOS/Tuist/Config.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ProjectDescription

let config = Config()
85 changes: 85 additions & 0 deletions iOS/Tuist/ProjectDescriptionHelpers/Project+Templates.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import ProjectDescription

public extension Project {
static func makeModule(
name: String,
platform: Platform = .iOS,
product: Product,
organizationName: String = "kr.codesquad.boostcamp8",
packages: [Package] = [],
deploymentTarget: DeploymentTarget? = .iOS(targetVersion: "16.0", devices: [.iphone]),
dependencies: [TargetDependency] = [],
sources: SourceFilesList = ["Sources/**"],
resources: ResourceFileElements? = nil,
infoPlist: InfoPlist = .default,
isTestable: Bool = false)
-> Project {

let settings: Settings = .settings(
base: [:],
configurations: [
.debug(name: .debug),
.release(name: .release)
],
defaultSettings: .recommended)

let appTarget = Target(
name: name,
platform: platform,
product: product,
bundleId: "\(organizationName).\(name)",
deploymentTarget: deploymentTarget,
infoPlist: infoPlist,
sources: sources,
resources: resources,
scripts: [.swiftLint, .swiftFormat],
dependencies: dependencies)

let schemes: [Scheme] = [.makeScheme(target: .debug, name: name)]

var targets: [Target] = [appTarget]

if isTestable {
let testTarget = Target(
name: "\(name)Tests",
platform: platform,
product: .unitTests,
bundleId: "\(organizationName).\(name)Tests",
deploymentTarget: deploymentTarget,
infoPlist: .default,
sources: ["Tests/**"],
dependencies: [.target(name: name)]
)

targets.append(testTarget)
}

return Project(
name: name,
organizationName: organizationName,
packages: packages,
settings: settings,
targets: targets,
schemes: schemes)
}
}

extension Scheme {
///Scheme을 만드는 메소드
static func makeScheme(target: ConfigurationName, name: String) -> Scheme {
return Scheme(
name: name,
shared: true,
buildAction: .buildAction(targets: ["\(name)"]),
testAction: .targets(
["\(name)Tests"],
configuration: target,
options: .options(coverage: true, codeCoverageTargets: ["\(name)"])
),
runAction: .runAction(configuration: target),
archiveAction: .archiveAction(configuration: target),
profileAction: .profileAction(configuration: target),
analyzeAction: .analyzeAction(configuration: target)
)
}
}
Loading

0 comments on commit ffafffe

Please sign in to comment.