Skip to content

Commit cbf4ac8

Browse files
Update tuist, refactor and finalize tuist code
1 parent 893f373 commit cbf4ac8

15 files changed

+390
-322
lines changed

.mise.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[tools]
2-
tuist = "latest"
2+
tuist = "3.42.0"

Project.swift

+50-42
Original file line numberDiff line numberDiff line change
@@ -5,66 +5,44 @@
55
import ProjectDescription
66
import ProjectDescriptionHelpers
77

8-
private let deploymentTarget = "17.0"
8+
private let deploymentTargetVersion = "17.0"
99

1010
let project = Project.app(
1111
name: "Why-Not-SwiftUI",
12-
platform: .iOS,
13-
deploymentTarget: .iOS(
14-
targetVersion: deploymentTarget,
15-
devices: [.iphone, .ipad]
16-
),
12+
deploymentTargets: .iOS(deploymentTargetVersion),
13+
destinations: [.iPhone, .iPad, .macWithiPadDesign, .appleVisionWithiPadDesign],
1714
baseSettings: [
1815
// Signing
1916
"CODE_SIGN_STYLE": "Automatic",
2017
"DEVELOPMENT_TEAM": "UT4XSTUQLU",
2118

2219
// Version
23-
"MARKETING_VERSION": "1.0",
24-
"CURRENT_PROJECT_VERSION": "1",
20+
"MARKETING_VERSION": appVersion,
21+
"CURRENT_PROJECT_VERSION": appBuild,
22+
23+
"IPHONEOS_DEPLOYMENT_TARGET": "\(deploymentTargetVersion)",
24+
25+
// Recommended by Xcode
26+
"ENABLE_USER_SCRIPT_SANDBOXING": true
2527

2628
// Strict concurrency checking
2729
// NOTE: Will try later to make app read for Swift 6.
2830
// "SWIFT_STRICT_CONCURRENCY": "complete"
29-
30-
"IPHONEOS_DEPLOYMENT_TARGET": "\(deploymentTarget)"
31-
],
32-
additionalTargets: [
33-
Module(
34-
name: "Core",
35-
hasResources: true
36-
),
37-
Module(
38-
name: "CommonUI",
39-
hasResources: true,
40-
dependencies: ["Core"]
41-
),
42-
Module(
43-
name: "Home",
44-
dependencies: ["Core", "CommonUI"]
45-
)
46-
],
47-
externalDependencies: [
48-
.external(name: "Alamofire"),
49-
.external(name: "Moya"),
50-
.external(name: "CombineMoya"),
51-
.external(name: "Kingfisher"),
52-
.external(name: "DGCharts"),
53-
.external(name: "Lottie"),
54-
// SwiftMacros depends on a Swift Macro, which is not yet supported.
55-
//.external(name: "SwiftMacros")
5631
],
5732
infoPlist: [
33+
"CFBundleDisplayName": "$(XCC_PRODUCT_NAME)",
5834
"CFBundleShortVersionString": "$(MARKETING_VERSION)",
5935
"CFBundleVersion": "$(CURRENT_PROJECT_VERSION)",
60-
"UIMainStoryboardFile": "",
61-
"UILaunchStoryboardName": "LaunchScreen",
6236
"CFBundleName": "$(PRODUCT_NAME)",
6337
"CFBundleIdentifier": "$(PRODUCT_BUNDLE_IDENTIFIER)",
6438

6539
// We need this to detect jail-broken device.
6640
"LSApplicationQueriesSchemes": ["cydia"],
6741

42+
"UILaunchScreen": [
43+
"UILaunchScreen": []
44+
],
45+
6846
"UIAppFonts": [
6947
"SF-Pro-Rounded-Black.otf",
7048
"SF-Pro-Rounded-Bold.otf",
@@ -77,7 +55,7 @@ let project = Project.app(
7755
"SF-Pro-Rounded-Ultralight.otf",
7856
"RobotoSlab-VariableFont.ttf"
7957
],
80-
58+
8159
"UIBackgroundModes": [
8260
"remote-notification"
8361
],
@@ -91,9 +69,39 @@ let project = Project.app(
9169
"UIApplicationSupportsIndirectInputEvents": "TRUE",
9270

9371
"NSCameraUsageDescription": "Record video",
94-
"NSMicrophoneUsageDescription": "Record audio",
95-
96-
"CFBundleDisplayName": "$(XCC_PRODUCT_NAME)",
72+
"NSMicrophoneUsageDescription": "Record audio"
73+
],
74+
configInfoPlist: [
9775
"CONF_HOST_URL": "$(XCC_HOST_URL)"
98-
]
76+
],
77+
modules: [
78+
Module(
79+
name: "Core",
80+
hasResources: true,
81+
hasUnitTest: true
82+
),
83+
Module(
84+
name: "CommonUI",
85+
hasResources: true,
86+
hasUITest: true,
87+
dependencies: ["Core"]
88+
),
89+
Module(
90+
name: "Home",
91+
hasUnitTest: true,
92+
hasUITest: true,
93+
dependencies: ["Core", "CommonUI"]
94+
)
95+
],
96+
externalDependencies: [
97+
.external(name: "Alamofire"),
98+
.external(name: "Moya"),
99+
.external(name: "CombineMoya"),
100+
.external(name: "Kingfisher"),
101+
.external(name: "DGCharts"),
102+
.external(name: "Lottie"),
103+
// SwiftMacros depends on a Swift Macro, which is not yet supported.
104+
// .external(name: "SwiftMacros")
105+
],
106+
coreDataModels: []
99107
)

README.md

+74-10
Original file line numberDiff line numberDiff line change
@@ -95,54 +95,118 @@ Total 3 playground related to date formatting. Inspired by [NSDateFormatter.com]
9595

9696
## Project Setup
9797

98+
## Project Setup
99+
98100
This project is using [Tuist](https://tuist.io). To run the project we need some initial setup.
99101

100-
### Step 1: Install Tuist (One time setup)
102+
### Step 1: Install [mise](https://mise.jdx.dev/)
103+
104+
We need `mise` to install `Tuist` and for maintaining project based `Tuist` versioning.
101105

102-
Install Tuist using the following command:
106+
Install `mise` CLI:
103107

104108
```bash
105-
curl -Ls https://install.tuist.io | bash
109+
# Install CLI
110+
$ curl https://mise.jdx.dev/install.sh | sh
111+
112+
# Check mise version
113+
$ ~/.local/bin/mise --version
114+
mise xxxx.x.x
115+
116+
# Add mise to Zsh configuration file (`.zshrc`) for auto activate mise
117+
$ echo 'eval "$(~/.local/bin/mise activate zsh)"' >> ~/.zshrc
106118
```
119+
Finally, restart your shell session to use `mise`.
107120

108-
### Step 2: Fetch dependencies
121+
### Step 2: Install `Tuist`
122+
123+
Install `Tuist` using the following command:
124+
125+
```bash
126+
mise install tuist
127+
```
109128

110-
We need to fetch the app dependencies. So use the following command to fetch the dependencies using Tuist.
129+
### Step 3: Clone repository and change directory to the repository
130+
131+
```bash
132+
git clone git@github.pie.apple.com:RDDM/MyStore.git
133+
cd MyStore
134+
```
135+
136+
### Step 4: Fetch dependencies
137+
138+
We need to fetch the app dependencies. So use the following command to fetch the dependencies using `Tuist`.
111139

112140
```bash
113141
tuist fetch
114142
```
115143

116144
### Step 3: Generate the project
117145

118-
Finally, create the project file using the following command:
146+
Finally, generate and open the project using the following command:
119147

120148
```bash
121149
tuist generate
122150
```
123151

124-
This will generate the project file and run the project in Xcode.
152+
This will generate the project file and open the project in Xcode.
125153

126154
### Notes
127155

128-
- As we are using Tuist to manage our Xcode project, use the following command to open the Tuist manifest files in Xcode for editing:
156+
- As we are using `Tuist` to manage our Xcode project, use the following command to open the Tuist manifest files in Xcode for editing:
129157

130158
```bash
131159
tuist edit
132160
```
133161

134-
- We have to run the `tuist fetch` every time we add or update dependency to our project.
162+
- We have to run the `tuist fetch` every time we change any dependency of our project.
163+
164+
- To upgrade dependency versions, use `tuist fetch --update` command.
165+
166+
- Always use `tuist generate` to open the project.
135167

136168
- After changing branch we also need to run the `tuist generate` command to generate project files.
137169

138170
- Please don't use Xcode Source Control. ([Issue](https://github.com/tuist/tuist/issues/4630))
139171

140-
Please see the [Tuist documentation](https://docs.tuist.io/tutorial/get-started) for details.
172+
Please see the [Tuist documentation](https://docs.tuist.io) for details.
141173

142174
## Project Map
143175

144176
![Project Map](graph.png)
145177

178+
## Directory Structure
179+
180+
- `Root`: Root directory
181+
- `ConfigurationFiles`: Configuration files
182+
- `CoreData`: Core Data models
183+
- `Entitlements`: Entitlements
184+
- `Targets`: Targets/Modules
185+
- `ModuleX`: An example target/module
186+
- `Resources`: Resource of `ModuleX`
187+
- `Sources`: Source codes of `ModuleX`
188+
- `Models`: All models for `ModuleX`
189+
- **Note**: Keep models screen/sheet name wise.
190+
- `UI`: All the UI files for `ModuleX`. It also contains `ViewModel`s.
191+
- `Components`: Common UI components that are shared in multiple screens
192+
- `Screens`: All screens, sheets etc.
193+
- `XYZ`: UI files for screen/sheet `XYZ`
194+
- `Components`: Common UI components for screen/sheet `XYZ`
195+
- `ABCView.swift`: Example component file
196+
- `XYZScreen.swift`: Example screen/sheet UI file
197+
- `XYZViewModel.swift`: Example view model file
198+
- `ViewModels`: Common `ViewModel`s for `ModuleX`.
199+
- `Tests`: Unit test target
200+
- `Resources`: Resource of `Tests`
201+
- `XYZTests.swift`: Example unit test file
202+
- `UITests`: UI test target
203+
- `Resources`: Resource of `UITests`
204+
- `XYZUITests.swift`: Example UI test file
205+
- `ModuleY`
206+
- `ModuleZ`
207+
- ...
208+
- `Tuist`: Tuist configuration files
209+
146210
# Tuist Cheat Sheet
147211

148212
## Access `Bundle`

Targets/CommonUI/Tests/BLANK_FILE.swift

Whitespace-only changes.

Targets/Core/UITests/BLANK_FILE.swift

Whitespace-only changes.

Tuist/Dependencies.swift

+2-13
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,8 @@
55
import ProjectDescription
66
import ProjectDescriptionHelpers
77

8-
let packages: [Package] = [
9-
.remote(url: "https://github.com/Alamofire/Alamofire", requirement: .upToNextMajor(from: "5.0.0")),
10-
.remote(url: "https://github.com/Moya/Moya", requirement: .upToNextMajor(from: "15.0.0")),
11-
.remote(url: "https://github.com/onevcat/Kingfisher", requirement: .upToNextMajor(from: "7.0.0")),
12-
.remote(url: "https://github.com/danielgindi/Charts", requirement: .upToNextMajor(from: "5.0.0")),
13-
.remote(url: "https://github.com/airbnb/lottie-ios", requirement: .upToNextMajor(from: "4.3.0")),
14-
.local(path: "packages/SwiftMacros")
15-
]
16-
178
let dependencies = Dependencies(
189
swiftPackageManager: .init(
19-
packages,
2010
productTypes: [
2111
"Alamofire": .framework,
2212
"Moya": .framework,
@@ -27,9 +17,8 @@ let dependencies = Dependencies(
2717
"SwiftMacros": .framework
2818
],
2919
baseSettings: Settings.settings(
30-
configurations: TargetBuildEnvironment.allConfigurations
31-
),
32-
targetSettings: [:]
20+
configurations: BuildEnvironment.getConfigurations(for: .target)
21+
)
3322
),
3423
platforms: [.iOS]
3524
)

Tuist/Package.swift

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// swift-tools-version: 5.8
2+
3+
//
4+
// Copyright © 2023 Md. Mahmudul Hasan Shohag. All rights reserved.
5+
//
6+
7+
import PackageDescription
8+
9+
let package = Package(
10+
name: "PackageName",
11+
dependencies: [
12+
.package(url: "https://github.com/Alamofire/Alamofire", from: "5.0.0"),
13+
.package(url: "https://github.com/Moya/Moya", from: "15.0.0"),
14+
.package(url: "https://github.com/onevcat/Kingfisher", from: "7.0.0"),
15+
.package(url: "https://github.com/danielgindi/Charts", from: "5.0.0"),
16+
.package(url: "https://github.com/airbnb/lottie-ios", from: "4.3.0"),
17+
.package(path: "packages/SwiftMacros")
18+
]
19+
)

Tuist/Packages.swift

-5
This file was deleted.

Tuist/ProjectDescriptionHelpers/AppExtensions.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import ProjectDescription
77
let appExtensions = [
88
Target(
99
name: "NotificationServiceExtension",
10-
platform: .iOS,
10+
destinations: [.iPhone, .iPad, .macWithiPadDesign, .appleVisionWithiPadDesign],
1111
product: .appExtension,
1212
bundleId: "\(Constants.bundleId).NotificationServiceExtension",
13+
deploymentTargets: .iOS("17.0"),
1314
infoPlist: .extendingDefault(with: [
1415
"CFBundleDisplayName": "$(PRODUCT_NAME)",
1516
"NSExtension": [
@@ -20,7 +21,7 @@ let appExtensions = [
2021
sources: "NotificationServiceExtension/**",
2122
dependencies: [],
2223
settings: .settings(
23-
configurations: NotificationServiceExtBuildEnvironment.allConfigurations
24+
configurations: BuildEnvironment.getConfigurations(for: .notificationServiceExtension)
2425
)
2526
)
2627
]

0 commit comments

Comments
 (0)