Skip to content

Commit

Permalink
Merge pull request #23 from boostcampwm2023/chore/iOS/swiftlint-swift…
Browse files Browse the repository at this point in the history
…format

[MGT-30] SwiftLint/SwiftFormat 적용
  • Loading branch information
SwiftyJunnos authored Nov 9, 2023
2 parents 6d841e7 + 7f28c71 commit 11a7109
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 64 deletions.
1 change: 1 addition & 0 deletions iOS/MaybeGamsung/.swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.9
11 changes: 11 additions & 0 deletions iOS/MaybeGamsung/.swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 코드 들여쓰기
--indent 4

# 공백 문자 삭제
--trimwhitespace always

# 줄 바꿈 문자 관리
--linebreaks lf #cr, lf, crlf

# wrapMultilineStatementBraces 비활성화
--disable wrapMultilineStatementBraces
27 changes: 27 additions & 0 deletions iOS/MaybeGamsung/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 한 라인 길이 제한
line_length:
warning: 120 #default: 120
error: 200

# 강제 형변환
force_cast: error
force_try: error

# 의미없는 공백/줄 바꿈
trailing_newline: warning
trailing_whitespace:
severity: warning

# 함수 길이 제한
function_body_length:
warning: 50
error: 100

# 타입 지정 시, 이름 조건
type_name:
min_length:
warning: 3
error: 0
max_length:
warning: 40
error: 1000
57 changes: 57 additions & 0 deletions iOS/MaybeGamsung/MaybeGamsung.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
2179E5EE2AFB94D500746FD8 /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = 2179E5ED2AFB94D500746FD8 /* .swiftlint.yml */; };
2179E5F22AFBA08800746FD8 /* .swiftformat in Resources */ = {isa = PBXBuildFile; fileRef = 2179E5F12AFBA08700746FD8 /* .swiftformat */; };
2179E5F42AFBA46300746FD8 /* .swift-version in Resources */ = {isa = PBXBuildFile; fileRef = 2179E5F32AFBA46300746FD8 /* .swift-version */; };
DD10AA2B2AFB874C00F5828A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD10AA2A2AFB874C00F5828A /* AppDelegate.swift */; };
DD10AA2D2AFB874C00F5828A /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD10AA2C2AFB874C00F5828A /* SceneDelegate.swift */; };
DD10AA2F2AFB874C00F5828A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD10AA2E2AFB874C00F5828A /* ViewController.swift */; };
Expand All @@ -16,6 +19,9 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
2179E5ED2AFB94D500746FD8 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = "<group>"; };
2179E5F12AFBA08700746FD8 /* .swiftformat */ = {isa = PBXFileReference; explicitFileType = text.yaml; path = .swiftformat; sourceTree = "<group>"; };
2179E5F32AFBA46300746FD8 /* .swift-version */ = {isa = PBXFileReference; lastKnownFileType = text; path = ".swift-version"; sourceTree = "<group>"; };
DD10AA272AFB874C00F5828A /* MaybeGamsung.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MaybeGamsung.app; sourceTree = BUILT_PRODUCTS_DIR; };
DD10AA2A2AFB874C00F5828A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
DD10AA2C2AFB874C00F5828A /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -40,6 +46,9 @@
DD10AA1E2AFB874C00F5828A = {
isa = PBXGroup;
children = (
2179E5F32AFBA46300746FD8 /* .swift-version */,
2179E5F12AFBA08700746FD8 /* .swiftformat */,
2179E5ED2AFB94D500746FD8 /* .swiftlint.yml */,
DD10AA292AFB874C00F5828A /* MaybeGamsung */,
DD10AA282AFB874C00F5828A /* Products */,
);
Expand Down Expand Up @@ -77,6 +86,8 @@
DD10AA232AFB874C00F5828A /* Sources */,
DD10AA242AFB874C00F5828A /* Frameworks */,
DD10AA252AFB874C00F5828A /* Resources */,
2179E5EF2AFB94ED00746FD8 /* Swift Lint */,
2179E5F02AFBA02700746FD8 /* Swift Format */,
);
buildRules = (
);
Expand Down Expand Up @@ -125,14 +136,58 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2179E5F22AFBA08800746FD8 /* .swiftformat in Resources */,
2179E5EE2AFB94D500746FD8 /* .swiftlint.yml in Resources */,
DD10AA372AFB874D00F5828A /* LaunchScreen.storyboard in Resources */,
DD10AA342AFB874D00F5828A /* Assets.xcassets in Resources */,
2179E5F42AFBA46300746FD8 /* .swift-version in Resources */,
DD10AA322AFB874C00F5828A /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
2179E5EF2AFB94ED00746FD8 /* Swift Lint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Swift Lint";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\nif which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
};
2179E5F02AFBA02700746FD8 /* Swift Format */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Swift Format";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\nif which swiftformat > /dev/null; then\n swiftformat .\nelse\n echo \"warning: SwiftFormat not installed, download from https://github.com/nicklockwood/SwiftFormat\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
DD10AA232AFB874C00F5828A /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -293,6 +348,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = B3PWYBKFUK;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = MaybeGamsung/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand Down Expand Up @@ -325,6 +381,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = B3PWYBKFUK;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = MaybeGamsung/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand Down
26 changes: 8 additions & 18 deletions iOS/MaybeGamsung/MaybeGamsung/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,18 @@ import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
func application(_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
func application(_: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options _: UIScene.ConnectionOptions) -> UISceneConfiguration {
UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


func application(_: UIApplication, didDiscardSceneSessions _: Set<UISceneSession>) {}
}

42 changes: 4 additions & 38 deletions iOS/MaybeGamsung/MaybeGamsung/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,11 @@
import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?


func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
}

func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}

func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}

func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
func scene(_ scene: UIScene,
willConnectTo _: UISceneSession,
options _: UIScene.ConnectionOptions) {
guard (scene as? UIWindowScene) != nil else { return }
}

func sceneWillEnterForeground(_ scene: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}

func sceneDidEnterBackground(_ scene: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}


}

12 changes: 4 additions & 8 deletions iOS/MaybeGamsung/MaybeGamsung/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}


// override func viewDidLoad() {
// super.viewDidLoad()
// // Do any additional setup after loading the view.
// }
}

0 comments on commit 11a7109

Please sign in to comment.