Skip to content

Commit

Permalink
feat: Demo make 명령어 구현
Browse files Browse the repository at this point in the history
- demo 앱을 빠르게 만들어줄 수 있도록 shell script와 Makefile을 손봤습니다.
  • Loading branch information
WhiteHyun committed Nov 19, 2023
1 parent cebd6ea commit c9c23df
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 0 deletions.
6 changes: 6 additions & 0 deletions iOS/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions iOS/Scripts/create_demo_module.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF > 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
21 changes: 21 additions & 0 deletions iOS/Tuist/Templates/Demo/AppDelegate.stencil
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)
}
}
24 changes: 24 additions & 0 deletions iOS/Tuist/Templates/Demo/Demo.swift
Original file line number Diff line number Diff line change
@@ -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"
)
]
)
25 changes: 25 additions & 0 deletions iOS/Tuist/Templates/Demo/LaunchScreen.stencil
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>
13 changes: 13 additions & 0 deletions iOS/Tuist/Templates/Demo/SceneDelegate.stencil
Original file line number Diff line number Diff line change
@@ -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()
}
}

0 comments on commit c9c23df

Please sign in to comment.