Skip to content

Commit

Permalink
[CAT-201] Xcode FileTemplate 추가 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
devMinseok authored Aug 12, 2024
1 parent eb8b3ec commit 44ce8ef
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 2 deletions.
30 changes: 30 additions & 0 deletions FileTemplate/TCA.xctemplate/Default/___FILEBASENAME___Core.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//___FILEHEADER___

import ComposableArchitecture

@Reducer
struct ___VARIABLE_productName___Core {
@ObservableState
struct State: Equatable {
<#properties#>
}

enum Action {
<#case#>
}

<#@Dependency() var#>

init() {}

var body: some ReducerOf<Self> {
Reduce(self.core)
}

private func core(state: inout State, action: Action) -> EffectOf<Self> {
switch action {
case <#pattern#>:
<#code#>
}
}
}
19 changes: 19 additions & 0 deletions FileTemplate/TCA.xctemplate/Default/___FILEBASENAME___View.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//___FILEHEADER___

import SwiftUI

import DesignSystem

import ComposableArchitecture

struct ___FILEBASENAME___: View {
@Bindable var store: StoreOf<___VARIABLE_productName___Core>

init(store: StoreOf<___VARIABLE_productName___Core>) {
self.store = store
}

var body: some View {
<#code#>
}
}
30 changes: 30 additions & 0 deletions FileTemplate/TCA.xctemplate/Public/___FILEBASENAME___Core.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//___FILEHEADER___

import ComposableArchitecture

@Reducer
public struct ___VARIABLE_productName___Core {
@ObservableState
public struct State: Equatable {
<#properties#>
}

public enum Action {
<#case#>
}

<#@Dependency() var#>

public init() {}

public var body: some ReducerOf<Self> {
Reduce(self.core)
}

private func core(state: inout State, action: Action) -> EffectOf<Self> {
switch action {
case <#pattern#>:
<#code#>
}
}
}
19 changes: 19 additions & 0 deletions FileTemplate/TCA.xctemplate/Public/___FILEBASENAME___View.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//___FILEHEADER___

import SwiftUI

import DesignSystem

import ComposableArchitecture

public struct ___FILEBASENAME___: View {
@Bindable var store: StoreOf<___VARIABLE_productName___Core>

public init(store: StoreOf<___VARIABLE_productName___Core>) {
self.store = store
}

public var body: some View {
<#code#>
}
}
57 changes: 57 additions & 0 deletions FileTemplate/TCA.xctemplate/TemplateInfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kind</key>
<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
<key>Summary</key>
<string>TCA file template</string>
<key>Description</key>
<string>TCA file template</string>
<key>SortOrder</key>
<string>1</string>
<key>AllowedTypes</key>
<array>
<string>public.swift-source</string>
</array>
<key>DefaultCompletionName</key>
<string>View</string>
<key>MainTemplateFiles</key>
<string>___FILEBASENAME___.swift</string>
<key>Platforms</key>
<array>
<string>com.apple.platform.iphoneos</string>
</array>
<key>Options</key>
<array>
<dict>
<key>Identifier</key>
<string>productName</string>
<key>Required</key>
<string>true</string>
<key>Name</key>
<string>{Name}View, {Name}Core</string>
<key>Description</key>
<string></string>
<key>Type</key>
<string>text</string>
<key>NotPersisted</key>
<string>true</string>
</dict>
<dict>
<key>Identifier</key>
<string>Public</string>
<key>Required</key>
<string>false</string>
<key>Name</key>
<string>Make Public</string>
<key>Description</key>
<string></string>
<key>Type</key>
<string>checkbox</string>
<key>NotPersisted</key>
<string>true</string>
</dict>
</array>
</dict>
</plist>
19 changes: 19 additions & 0 deletions FileTemplate/install_template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env sh

XCODE_TEMPLATE_DIR=$HOME'/Library/Developer/Xcode/Templates/File Templates/PomoNyang'
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

xcodeTemplate () {
echo "==> Copying up templates..."

if [ -d "$XCODE_TEMPLATE_DIR" ]; then
rm -R "$XCODE_TEMPLATE_DIR"
fi
mkdir -p "$XCODE_TEMPLATE_DIR"

cp -R $SCRIPT_DIR/*.xctemplate "$XCODE_TEMPLATE_DIR"
}

xcodeTemplate

echo "==> ... success!"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ graph:

.PHONY: template
template:
sh file_template/install_template.sh
sh FileTemplate/install_template.sh
2 changes: 1 addition & 1 deletion SwiftLint/swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
excluded:
- ${PWD}/DerivedData
- ../file_template
- ../FileTemplate
- ../Tuist
- ../Plugins
- ../Workspace.swift
Expand Down

0 comments on commit 44ce8ef

Please sign in to comment.