diff --git a/iOS/Makefile b/iOS/Makefile index 1d53f05c..424b5d2e 100644 --- a/iOS/Makefile +++ b/iOS/Makefile @@ -7,6 +7,12 @@ feature: @./Scripts/create_feature_module.sh tuist edit +demo: + chmod +x Scripts/create_demo_module.sh + @./Scripts/create_demo_module.sh + tuist edit + + test: tuist clean tuist fetch diff --git a/iOS/Scripts/create_demo_module.sh b/iOS/Scripts/create_demo_module.sh new file mode 100755 index 00000000..5004c5c0 --- /dev/null +++ b/iOS/Scripts/create_demo_module.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# Tuist Demo Module 생성을 편리하게 하고자 만들어진 스크립트 파일입니다. + +# Feature 이름 받기 +read -p "만들고자 할 Demo모듈의 이름을 작성하세요: " name + + +# 첫 글자가 대문자인 경우 소문자로 변환하여 enum case 변수 설정 +if [[ $name =~ ^[A-Z] ]]; then + enum_case_name="$(tr '[:upper:]' '[:lower:]' <<< ${name:0:1})${name:1}" +else + enum_case_name="$name" +fi + +# 첫 글자가 소문자인 경우에만 대문자로 변환 +if [[ $name =~ ^[a-z] ]]; then + name="$(tr '[:lower:]' '[:upper:]' <<< ${name:0:1})${name:1}" +fi + + +tuist scaffold Demo --name "$name" + +# Project.swift 파일 생성 +cat < Projects/App/$name/Project.swift +import DependencyPlugin +import ProjectDescription +import ProjectDescriptionHelpers + +let project = Project.makeModule( + name: "${name}Demo", + product: .app, + dependencies: [ + ], + resources: ["Resources/**"], + infoPlist: .extendingDefault( + with: [ + "UILaunchStoryboardName": "LaunchScreen", + "UIApplicationSceneManifest": [ + "UIApplicationSupportsMultipleScenes": false, + "UISceneConfigurations": [ + "UIWindowSceneSessionRoleApplication": [ + [ + "UISceneConfigurationName": "Default Configuration", + "UISceneDelegateClassName": "$(PRODUCT_MODULE_NAME).SceneDelegate", + ], + ], + ], + ], + ] + ) +) +EOF diff --git a/iOS/Tuist/Templates/Demo/AppDelegate.stencil b/iOS/Tuist/Templates/Demo/AppDelegate.stencil new file mode 100644 index 00000000..1ffc70ad --- /dev/null +++ b/iOS/Tuist/Templates/Demo/AppDelegate.stencil @@ -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) + } +} diff --git a/iOS/Tuist/Templates/Demo/Demo.swift b/iOS/Tuist/Templates/Demo/Demo.swift new file mode 100644 index 00000000..13e86dff --- /dev/null +++ b/iOS/Tuist/Templates/Demo/Demo.swift @@ -0,0 +1,24 @@ +import ProjectDescription + +private let nameAttribute = Template.Attribute.required("name") + +private let template = Template( + description: "A template for a new module's demo target", + attributes: [ + nameAttribute + ], + items: [ + .file( + path: "Projects/App/\(nameAttribute)/Resources/LaunchScreen.storyboard", + templatePath: "LaunchScreen.stencil" + ), + .file( + path: "Projects/App/\(nameAttribute)/Sources/Application/AppDelegate.swift", + templatePath: "AppDelegate.stencil" + ), + .file( + path: "Projects/App/\(nameAttribute)/Sources/Application/SceneDelegate.swift", + templatePath: "SceneDelegate.stencil" + ) + ] +) diff --git a/iOS/Tuist/Templates/Demo/LaunchScreen.stencil b/iOS/Tuist/Templates/Demo/LaunchScreen.stencil new file mode 100644 index 00000000..865e9329 --- /dev/null +++ b/iOS/Tuist/Templates/Demo/LaunchScreen.stencil @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS/Tuist/Templates/Demo/SceneDelegate.stencil b/iOS/Tuist/Templates/Demo/SceneDelegate.stencil new file mode 100644 index 00000000..f8178623 --- /dev/null +++ b/iOS/Tuist/Templates/Demo/SceneDelegate.stencil @@ -0,0 +1,13 @@ +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 } + let navigationController = UINavigationController() + window = UIWindow(windowScene: windowScene) + window?.rootViewController = navigationController + window?.makeKeyAndVisible() + } +}