Skip to content

Commit a4857e0

Browse files
author
Mohammed Rokon Uddin
authored
Merge pull request #20 from rokon-uddin/update_template
chore: update template and drop version for iOS 15
2 parents 6d1bdd3 + e42de50 commit a4857e0

File tree

18 files changed

+394
-329
lines changed

18 files changed

+394
-329
lines changed

README.md

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## iOS Project Template for SwiftUI
2-
[![IDE](https://img.shields.io/badge/Xcode-14-blue.svg)](https://developer.apple.com/xcode/)
3-
[![Language](https://img.shields.io/badge/swift-5.5-orange.svg)](https://swift.org)
4-
[![Platform](https://img.shields.io/badge/iOS-15-green.svg)](https://developer.apple.com/ios/)
2+
[![IDE](https://img.shields.io/badge/Xcode-15-blue.svg)](https://developer.apple.com/xcode/)
3+
[![Language](https://img.shields.io/badge/swift-5.9-orange.svg)](https://swift.org)
4+
[![Platform](https://img.shields.io/badge/iOS-16-green.svg)](https://developer.apple.com/ios/)
55
[![Build Status](https://github.com/monstar-lab-oss/swiftui-template-tca/actions/workflows/build.yml/badge.svg)](https://github.com/monstar-lab-oss/swiftui-template-tca/actions/workflows/build.yml)
66

77

@@ -18,14 +18,11 @@ This template will save those hours and help to follow standard project architec
1818
* [R.swift](https://github.com/mac-cain13/R.swift) Get strong typed, autocompleted resources like images, fonts and segues in Swift projects
1919
* [Standard gitignore](https://github.com/github/gitignore/blob/master/Swift.gitignore)
2020
* [Moya](https://github.com/Moya/Moya) for netwoking layer
21-
* [Swiftlint](https://github.com/realm/SwiftLint) [SwiftLint SPM Plugin showing build error]
22-
* [Swinject](https://github.com/Swinject/Swinject) [Swinject SPM Plugin showing build error]
23-
* Development/Staging/Production app flavours
21+
* [Swift-Format](https://github.com/apple/swift-format) [For doing code formatting transformations]
22+
* Development, Staging and Production app flavours
2423
* Separate build configuration for each flavour
2524

2625
### Todo
27-
* Database Platform
28-
* Persistency Platform
2926
* Base classes for handling deeplink, notifications and multiple scheme
3027

3128
### Supporting Tools
@@ -72,8 +69,8 @@ Please refer to [Contributing Guidelines](https://github.com/monstar-lab-oss/swi
7269

7370
## Acknowledgments
7471

75-
* [iOS project best practices and tools](https://medium.com/@piotr.gorzelany/ios-project-best-practices-and-tools-c46135b8116d)
76-
* [Development/Staging/Production Configs in Xcode](https://medium.com/better-programming/how-to-create-development-staging-and-production-configs-in-xcode-ec58b2cc1df4)
72+
* [iOS Project Best Practices and Tools](https://medium.com/@piotr.gorzelany/ios-project-best-practices-and-tools-c46135b8116d)
73+
* [Development, Staging and Production Configs in Xcode](https://medium.com/better-programming/how-to-create-development-staging-and-production-configs-in-xcode-ec58b2cc1df4)
7774
* [iOS Build Management using Custom Build Scheme](https://www.talentica.com/blogs/ios-build-management-using-custom-build-scheme/)
7875

7976
## 👥 Credits

TCA.xctemplate/TemplateInfo.plist

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>SupportsSwiftPackage</key>
6+
<true/>
57
<key>DefaultCompletionName</key>
68
<string>File</string>
79
<key>Summary</key>
@@ -63,8 +65,6 @@
6365
<string>static</string>
6466
</dict>
6567
</array>
66-
<key>SupportsSwiftPackage</key>
67-
<true/>
6868
<key>SortOrder</key>
6969
<string>7</string>
7070
</dict>

TCA.xctemplate/___FILEBASENAME___/___FILEBASENAME___Feature.swift

+37-33
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,60 @@ import ComposableArchitecture
1111
import Domain
1212
import Foundation
1313

14-
public struct ___VARIABLE_moduleName___Feature: Reducer {
14+
public struct ___VARIABLE_moduleName___Feature: FeatureReducer {
1515

16-
public struct State: Equatable {
16+
public init() {}
17+
18+
@ObservableState
19+
public struct State: Equatable, Hashable {
1720
public init() {}
1821
}
1922

20-
public enum Action: BaseAction {
23+
public enum ViewAction {
2124

22-
enum ViewAction: Equatable {
23-
case onAppear
25+
}
2426

25-
}
27+
public enum InternalAction {
2628

27-
enum InlyingAction: Equatable {
29+
}
2830

29-
}
31+
public var body: some ReducerOf<Self> {
3032

31-
enum DelegateAction: Equatable {
33+
}
3234

33-
}
35+
public func reduce(into state: inout State, viewAction: ViewAction) -> Effect<Action> {
36+
switch viewAction {
3437

35-
case view(ViewAction)
36-
case inlying(InlyingAction)
37-
case delegate(DelegateAction)
38+
}
3839
}
3940

40-
public func reduce(into state: inout State, action: Action) -> Effect<Action> {
41-
switch action {
42-
case .view(let action):
43-
switch action {
44-
case .onAppear:
45-
return .none
41+
public func reduce(into state: inout State, presentedAction: Destination.Action) -> Effect<Action> {
4642

47-
}
48-
case .inlying(let action):
49-
switch action {
43+
}
5044

51-
}
52-
case .delegate(let action):
53-
switch action {
45+
public func reduce(into state: inout State, internalAction: InternalAction) -> Effect<Action> {
46+
switch internalAction {
5447

55-
}
5648
}
5749
}
5850

59-
// Remove commented code if not needed
60-
// public var body: some Reducer<State, Action> {
61-
//
62-
// Reduce { state, action in
63-
//
64-
// }
65-
// }
51+
public struct Destination: DestinationReducer {
52+
53+
public init() {}
54+
55+
@dynamicMemberLookup
56+
@CasePathable
57+
public enum State: Hashable {
58+
59+
}
60+
61+
@CasePathable
62+
public enum Action {
63+
64+
}
65+
66+
public var body: some ReducerOf<Self> {
67+
68+
}
69+
}
6670
}

TCA.xctemplate/___FILEBASENAME___/___FILEBASENAME___View.swift

+13-12
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,25 @@
66
//___COPYRIGHT___
77
//
88

9+
import SwiftUI
910
import Commons
10-
import ComposableArchitecture
1111
import Resources
12-
import SwiftUI
12+
import ComposableArchitecture
1313

1414
public struct ___VARIABLE_moduleName___View: View {
15-
let store: StoreOf<___VARIABLE_moduleName___Feature>
15+
let store: StoreOf<___VARIABLE_moduleName___Feature>
1616

17-
public init(store: StoreOf<___VARIABLE_moduleName___Feature>) {
18-
self.store = store
19-
}
17+
public init(store: StoreOf<___VARIABLE_moduleName___Feature>) {
18+
self.store = store
19+
}
2020

21-
public var body: some View {
22-
WithViewStore(self.store, observe: { $0 }) { viewStore in
23-
Text("Hello World!!!")
24-
.onAppear {
25-
viewStore.send(.onAppear)
21+
public var body: some View {
22+
WithPerceptionTracking {
23+
Text("Hello World!!!")
24+
.onAppear {
25+
// Just for example
26+
// store.send(.onAppear)
27+
}
2628
}
2729
}
28-
}
2930
}

{{cookiecutter.app_name}}/ApplicationModules/Sources/Authentication/R.generated.swift

+30-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let R = _R(bundle: Bundle.module)
1010

1111
struct _R {
1212
let bundle: Foundation.Bundle
13-
var color:color { .init(bundle: bundle) }
13+
var color: color { .init(bundle: bundle) }
1414
var image: image { .init(bundle: bundle) }
1515

1616
func color(bundle: Foundation.Bundle) -> color {
@@ -23,35 +23,56 @@ struct _R {
2323

2424
}
2525

26-
2726
/// This `_R.color` struct is generated, and contains static references to 3 colors.
2827
struct color {
2928
let bundle: Foundation.Bundle
3029

3130
/// Color `BgColor`.
32-
var bgColor: ColorResource { .init(name: "BgColor", path: [], bundle: bundle) }
31+
var bgColor: ColorResource {
32+
.init(name: "BgColor", path: [], bundle: bundle)
33+
}
3334

3435
/// Color `PrimaryColor`.
35-
var primaryColor: ColorResource { .init(name: "PrimaryColor", path: [], bundle: bundle) }
36+
var primaryColor: ColorResource {
37+
.init(name: "PrimaryColor", path: [], bundle: bundle)
38+
}
3639

3740
/// Color `TitleTextColor`.
38-
var titleTextColor: ColorResource { .init(name: "TitleTextColor", path: [], bundle: bundle) }
41+
var titleTextColor: ColorResource {
42+
.init(name: "TitleTextColor", path: [], bundle: bundle)
43+
}
3944
}
4045

4146
/// This `_R.image` struct is generated, and contains static references to 4 images.
4247
struct image {
4348
let bundle: Foundation.Bundle
4449

4550
/// Image `apple`.
46-
var apple: ImageResource { .init(name: "apple", path: [], bundle: bundle, locale: nil, onDemandResourceTags: nil) }
51+
var apple: ImageResource {
52+
.init(
53+
name: "apple", path: [], bundle: bundle, locale: nil,
54+
onDemandResourceTags: nil)
55+
}
4756

4857
/// Image `fork_icon`.
49-
var fork_icon: ImageResource { .init(name: "fork_icon", path: [], bundle: bundle, locale: nil, onDemandResourceTags: nil) }
58+
var fork_icon: ImageResource {
59+
.init(
60+
name: "fork_icon", path: [], bundle: bundle, locale: nil,
61+
onDemandResourceTags: nil)
62+
}
5063

5164
/// Image `google`.
52-
var google: ImageResource { .init(name: "google", path: [], bundle: bundle, locale: nil, onDemandResourceTags: nil) }
65+
var google: ImageResource {
66+
.init(
67+
name: "google", path: [], bundle: bundle, locale: nil,
68+
onDemandResourceTags: nil)
69+
}
5370

5471
/// Image `onboard`.
55-
var onboard: ImageResource { .init(name: "onboard", path: [], bundle: bundle, locale: nil, onDemandResourceTags: nil) }
72+
var onboard: ImageResource {
73+
.init(
74+
name: "onboard", path: [], bundle: bundle, locale: nil,
75+
onDemandResourceTags: nil)
76+
}
5677
}
5778
}

{{cookiecutter.app_name}}/Common/Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PackageDescription
55

66
let package = Package(
77
name: "Common",
8-
platforms: [.macOS(.v12), .iOS(.v15)],
8+
platforms: [.macOS(.v12), .iOS(.v16)],
99
products: [
1010
.library(
1111
name: "Common",

{{cookiecutter.app_name}}/Common/Sources/Common/FeatureReducer.swift

+32
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,35 @@ public enum EmptyDestination: DestinationReducer {
116116
Action
117117
> { .none }
118118
}
119+
120+
extension FeatureReducer {
121+
122+
public func delayedMediumEffect(internal internalAction: InternalAction)
123+
-> Effect<Action>
124+
{
125+
self.delayedMediumEffect(for: .internal(internalAction))
126+
}
127+
128+
public func delayedMediumEffect(
129+
for action: Action
130+
) -> Effect<Action> {
131+
delayedEffect(delay: .seconds(0.6), for: action)
132+
}
133+
134+
public func delayedShortEffect(
135+
for action: Action
136+
) -> Effect<Action> {
137+
delayedEffect(delay: .seconds(0.3), for: action)
138+
}
139+
140+
private func delayedEffect(
141+
delay: Duration,
142+
for action: Action
143+
) -> Effect<Action> {
144+
@Dependency(\.continuousClock) var clock
145+
return .run { send in
146+
try await clock.sleep(for: delay)
147+
await send(action)
148+
}
149+
}
150+
}

{{cookiecutter.app_name}}/Domain/Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PackageDescription
55

66
let package = Package(
77
name: "Domain",
8-
platforms: [.macOS(.v12), .iOS(.v15)],
8+
platforms: [.macOS(.v12), .iOS(.v16)],
99
products: [
1010
.library(
1111
name: "Domain",

{{cookiecutter.app_name}}/Features/Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PackageDescription
55

66
let package = Package(
77
name: "Features",
8-
platforms: [.macOS(.v12), .iOS(.v15)],
8+
platforms: [.macOS(.v12), .iOS(.v16)],
99
products: [
1010
.library(
1111
name: "App",

0 commit comments

Comments
 (0)