Skip to content

Commit 2239adb

Browse files
authored
feat: Move to tuist as a project generation tool
2 parents c8dc127 + 616cc2f commit 2239adb

File tree

74 files changed

+396
-1448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+396
-1448
lines changed

README.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# iOS-Starter
22

3-
![version](https://img.shields.io/badge/version-v0.5.1-green)
3+
![version](https://img.shields.io/badge/version-v1.0.0-green)
44

55
This is a template project for boostrapping iOS applications
66

77
## Prequisites
88

9-
Install [cookiecutter](https://cookiecutter.readthedocs.io/en/latest/index.html),[XcodeGen](https://github.com/yonaskolb/XcodeGen) and [Mint](https://github.com/yonaskolb/Mint) in order to create a new project from this template:
9+
Install [cookiecutter](https://cookiecutter.readthedocs.io/en/latest/index.html),[tuist](https://github.com/tuist/tuist) and [Mint](https://github.com/yonaskolb/Mint) in order to create a new project from this template:
1010

1111
```sh
1212
brew install cookiecutter
13-
brew install xcodegen
13+
bash <(curl -Ls https://install.tuist.io)
1414
brew install mint
1515
```
1616

@@ -25,7 +25,7 @@ cookiecutter https://github.com/alexanderwe/ios-starter.git
2525
- Apple Developer Team details
2626
- other details necessary for the project
2727
- `cookiecutter` will create all necessary files
28-
- `XcodeGen` runs and automatically creates a `.xcodeproj` file
28+
- `tuist` runs and automatically creates a `.xcodeproj` file
2929
- Afterwards `mint bootstratp` will run to download all necessary build tools
3030
- Finally `Xcode` will launch your new project
3131
- All code dependencies are managed with the `Swift Package Manager`
@@ -36,45 +36,44 @@ cookiecutter https://github.com/alexanderwe/ios-starter.git
3636
- Logging Helper
3737
- [LoggingKit](https://github.com/alexanderwe/LoggingKit) - A small micro-framework for logging
3838
- Code Style
39-
- [SwiftLint](https://www.github.com/realm/SwiftLint) - Common linting rules
40-
- Helpers
41-
- [Rswift](https://github.com/mac-cain13/R.swift) - Type safe access to string resources
39+
- [swiftformat](https://github.com/nicklockwood/SwiftFormat) - Format and lint your source code
40+
4241

4342
## Structure
4443

45-
The structure of the template project tries to follow the idea in [this article](https://theswiftdev.com/2016/07/06/conventions-for-xcode/) from `The.Swift.Dev`
44+
The structure of the template project tries to follow the idea of having a directory for each of your target. In each of these targets you can find it sources and the corresponding tests.
4645

4746
External dependencies are managed via `Swift Package Manager`. Therefore it is mandatory to use **Xcode 11**.
4847

4948
### External build tools
5049

51-
External build tools like `swiftlint` and `R.swift` are managed by `Mint` This is necessary because the `Swift Package Manager` is not handling binaries, and therefore `Mint` is doing this job for us.
50+
External build tools like `swiftformat` are managed by `Mint`.
5251

5352
### Modules
5453

5554
The project is divided into several modules:
5655

57-
- `iOSApplication` - Contains UI code, navigation flows, views if used for SwiftUI or view controllers when UIKit is used
58-
- `iOSApplicationTests` - Unit tests for the iOS application
59-
- `iOSApplicationUITests` - UI tests for the iOS application
56+
- `iOS` - Contains UI code, navigation flows, views if used for SwiftUI or view controllers when UIKit is used
57+
- `Tests iOS` - Unit tests for the iOS application
58+
- `UI Tests iOS` - UI tests for the iOS application
6059
- `<ProjectName>Kit` - Source files for your service layer or generally speaking files that could be reused for example for an macOS or watchOS target
61-
- `<ProjectName>KitTests` - Unit test for the `<ProjectName>Kit` target
60+
- `<ProjectName>Kit Tests` - Unit test for the `<ProjectName>Kit` target
6261

6362
### Schemes
6463

65-
In general each target has its own scheme but the `iOSApplication` target has three:
64+
In general each target has its own scheme but the `iOS` target has three:
6665

6766
- development
6867
- staging
6968
- production
7069

71-
Each scheme is used in combination with the files located in `iOSApplication/SupportingFiles/Config`. There you can find four different files. Three for each scheme and one which contains the values for the active configuration. Each scheme has a `pre-build` action which copies the content from one of "release type" configs to `Configuration.xcconfig` which is then used when the app is running.
70+
Each scheme is used in combination with the files located in `Targets/iOS/SupportingFiles/Config`. There you can find four different files. Three for each scheme and one which contains the values for the active configuration. Each scheme has a `pre-build` action which copies the content from one of "release type" configs to `Configuration.xcconfig` which is then used when the app is running.
7271

7372
So for example if you are running the `iOS Applcation staging` scheme, the content of the `Staging.xcconfig` file is copied over to `Configuration.xcconfig` and can then be used within the app.
7473

7574
Currently this mechanism is used to change the app identifier and set some environment variable. This can be extended to for example use different backend urls for different schemes.
7675

77-
If you want to access one of the variables you declare inside the `.xcconfig` files you need to make them accessible to the app by putting them into the `iOSApplication/Sources/SupportingFiles/Info.plist` file. As an example you can have a look at the `_ServerEnvironment` variable which is later accessed within the `ViewController`.
76+
If you want to access one of the variables you declare inside the `.xcconfig` files you need to make them accessible to the app by putting them into the `Derived/InfoPlists/<Info.plist file for iOS target>` file. As an example you can have a look at the `_ServerEnvironment` variable which is later accessed within the `ViewController`.
7877

7978
#### External configuration files
8079

@@ -88,7 +87,7 @@ The mechanism described above can also be used for external configuration files.
8887
Inside the `pre-build` actions for the different schemes you copy the content of the corresponding file to `GoogleService-Info.plist` which is then used by your Google frameworks in the app. Such an `pre-build` command could like like the following.
8988

9089
```sh
91-
cp -f "${PROJECT_DIR}/iOSApplication/SupportingFiles/Config/Firebase/GoogleService-Info.development.plist" "${PROJECT_DIR}/iOSApplication/SupportingFiles/Config/Firebase/GoogleService-Info.plist"
90+
cp -f "${PROJECT_DIR}/Targets/iOS/SupportingFiles/Config/Firebase/GoogleService-Info.development.plist" "${PROJECT_DIR}/Targets/iOS/SupportingFiles/Config/Firebase/GoogleService-Info.plist"
9291
```
9392

9493
### UIKit or SwiftUI
@@ -112,7 +111,7 @@ The template uses [fastlane](https://fastlane.tools) for CI/CD. It comes with a
112111
Be sure to run `bundle install` first and then execute fastlane through `bundle exec`.
113112

114113
```sh
115-
bundle exec fastlane run tests
114+
bundle exec fastlane tests
116115
```
117116

118117
### Included Actions

cookiecutter.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
{
22
"projectName": "Example",
3-
"projectDirectory": "{{cookiecutter.projectName|lower|replace(' ', '-')}}-ios",
3+
"projectDirectory": "{{cookiecutter.projectName|lower|replace(' ', '-')}}",
44
"teamId": "TeamID",
55
"teamName": "TeamName",
66
"companyName": "CompanyName",
77
"bundleIdentifier": "com.example.{{cookiecutter.projectName|lower|replace(' ', '-')}}",
8-
"deploymentTarget": "13.0",
9-
"runMintBootstrap": "y",
10-
"runXcodeGen": "y",
8+
"deploymentTarget": "14.0",
119
"gitRepository": "https://github.com/alexanderwe/ios-starter.git",
1210
"_copy_without_render": [
1311
"*.tpl.md"

hooks/post_gen_project.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
11
#! /bin/bash
22

3-
# Run xcodegen to create .xcodeproj file
4-
{%- if cookiecutter.runXcodeGen == 'y' %}
5-
xcodegen
6-
{%- endif %}
7-
8-
# Install Mint dependecies
9-
{%- if cookiecutter.runMintBootstrap == 'y' %}
10-
mint bootstrap
11-
{%- endif %}
12-
13-
# If xcodegen has generated a .xcodeproj file we want to open it
14-
{%- if cookiecutter.runXcodeGen == 'y' %}
15-
xed .
16-
{%- endif %}
3+
# Run tuist to create .xcodeproj file
4+
tuist generate
175

186
# Set up git
197
git init
208

9+
# If tuist has generated a .xcodeproj file we want to open it
10+
xed .
11+
2112
## Configure git hooks
2213
chmod +x ./.githooks/commit-msg
2314
git config core.hooksPath .githooks
Lines changed: 18 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,10 @@
1-
# Custom ignores
2-
3-
*.generated.swift
4-
5-
6-
7-
# Created by https://www.gitignore.io/api/xcode,swift,macos,swiftpm,cocoapods,swiftpackagemanager
8-
# Edit at https://www.gitignore.io/?templates=xcode,swift,macos,swiftpm,cocoapods,swiftpackagemanager
9-
10-
### CocoaPods ###
11-
## CocoaPods GitIgnore Template
12-
13-
# CocoaPods - Only use to conserve bandwidth / Save time on Pushing
14-
# - Also handy if you have a large number of dependant pods
15-
# - AS PER https://guides.cocoapods.org/using/using-cocoapods.html NEVER IGNORE THE LOCK FILE
16-
Pods/
17-
181
### macOS ###
192
# General
203
.DS_Store
214
.AppleDouble
225
.LSOverride
236

24-
# Icon must end with two \r
7+
# Icon must end with two
258
Icon
269

2710
# Thumbnails
@@ -43,16 +26,22 @@ Network Trash Folder
4326
Temporary Items
4427
.apdisk
4528

46-
### Swift ###
29+
### Xcode ###
4730
# Xcode
4831
#
4932
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
5033

51-
## Build generated
34+
## User settings
35+
xcuserdata/
36+
37+
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
38+
*.xcscmblueprint
39+
*.xccheckout
40+
41+
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
5242
build/
5343
DerivedData/
54-
55-
## Various settings
44+
*.moved-aside
5645
*.pbxuser
5746
!default.pbxuser
5847
*.mode1v3
@@ -61,84 +50,18 @@ DerivedData/
6150
!default.mode2v3
6251
*.perspectivev3
6352
!default.perspectivev3
64-
xcuserdata/
65-
66-
## Other
67-
*.moved-aside
68-
*.xccheckout
69-
*.xcscmblueprint
70-
71-
## Obj-C/Swift specific
72-
*.hmap
73-
*.ipa
74-
*.dSYM.zip
75-
*.dSYM
7653

77-
## Playgrounds
78-
timeline.xctimeline
79-
playground.xcworkspace
80-
81-
# Swift Package Manager
82-
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
83-
# Packages/
84-
# Package.pins
85-
# Package.resolved
86-
.build/
87-
88-
# CocoaPods
89-
# We recommend against adding the Pods directory to your .gitignore. However
90-
# you should judge for yourself, the pros and cons are mentioned at:
91-
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
92-
# Pods/
93-
# Add this line if you want to avoid checking in source code from the Xcode workspace
94-
# *.xcworkspace
95-
96-
# Carthage
97-
# Add this line if you want to avoid checking in source code from Carthage dependencies.
98-
# Carthage/Checkouts
99-
100-
Carthage/Build
101-
102-
# Accio dependency management
103-
Dependencies/
104-
.accio/
105-
106-
# fastlane
107-
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
108-
# screenshots whenever they are needed.
109-
# For more information about the recommended setup visit:
110-
# https://docs.fastlane.tools/best-practices/source-control/#source-control
111-
112-
fastlane/report.xml
113-
fastlane/Preview.html
114-
fastlane/screenshots/**/*.png
115-
fastlane/test_output
116-
117-
# Code Injection
118-
# After new code Injection tools there's a generated folder /iOSInjectionProject
119-
# https://github.com/johnno1962/injectionforxcode
120-
121-
iOSInjectionProject/
122-
123-
### Xcode ###
124-
# Xcode
125-
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
126-
127-
## User settings
128-
129-
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
130-
131-
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
132-
133-
## Xcode Patch
54+
### Xcode Patch ###
13455
*.xcodeproj/*
13556
!*.xcodeproj/project.pbxproj
13657
!*.xcodeproj/xcshareddata/
13758
!*.xcworkspace/contents.xcworkspacedata
13859
/*.gcno
13960

140-
### Xcode Patch ###
141-
**/xcshareddata/WorkspaceSettings.xcsettings
142-
143-
# End of https://www.gitignore.io/api/xcode,swift,macos,swiftpm,cocoapods,swiftpackagemanager
61+
### Projects ###
62+
*.xcodeproj
63+
*.xcworkspace
14464

65+
### Tuist derived files ###
66+
graph.dot
67+
Derived/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
5.3
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# format options
2+
--indent tab
3+
--tabwidth 4
4+
5+
# Enabled rules
6+
--rules duplicateImports
7+
--rules elseOnSameLine
8+
--rules emptyBraces
9+
--rules hoistPatternLet
10+
--rules redundantParens
11+
12+
13+
# Disabled rules
14+
--disable indent #Rationale: Until decided, too many false positives
15+
--disable redundantType #Rationale: Sometimes it makes the code easier to understand to explicitly declare the type, even if its obvious for the compiler
16+
--disable redundantReturn #Rationale: Omitting the `return` keyword is a new feature in Swift 5.3. It could be confusing for new developers to omit it

0 commit comments

Comments
 (0)