This is a template project for boostrapping iOS applications
Install cookiecutter,tuist and Mint in order to create a new project from this template:
brew install cookiecutter
bash <(curl -Ls https://install.tuist.io)
brew install mint
cookiecutter https://github.com/alexanderwe/ios-starter.git
cookiecutter
will prompt you for:- The project name
- Apple Developer Team details
- other details necessary for the project
cookiecutter
will create all necessary filestuist
runs and automatically creates a.xcodeproj
file- Afterwards
mint bootstratp
will run to download all necessary build tools - Finally
Xcode
will launch your new project - All code dependencies are managed with the
Swift Package Manager
- Happy Coding !
- Logging Helper
- LoggingKit - A small micro-framework for logging
- Code Style
- swiftformat - Format and lint your source code
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.
External dependencies are managed via Swift Package Manager
. Therefore it is mandatory to use Xcode 11.
External build tools like swiftformat
are managed by Mint
.
The project is divided into several modules:
iOS
- Contains UI code, navigation flows, views if used for SwiftUI or view controllers when UIKit is usedTests iOS
- Unit tests for the iOS applicationUI Tests iOS
- UI tests for the iOS application<ProjectName>Kit
- Source files for your service layer or generally speaking files that could be reused for example for an macOS or watchOS target<ProjectName>Kit Tests
- Unit test for the<ProjectName>Kit
target
In general each target has its own scheme but the iOS
target has three:
- development
- staging
- production
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.
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.
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.
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
.
The mechanism described above can also be used for external configuration files. For example if you have a different GoogleService-Info.plist
for different builds of your app. Then you can create four different files:
- GoogleService-Info.development.plist
- GoogleService-Info.staging.plist
- GoogleService-Info.production.plist
- GoogleService-Info.plist
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.
cp -f "${PROJECT_DIR}/Targets/iOS/SupportingFiles/Config/Firebase/GoogleService-Info.development.plist" "${PROJECT_DIR}/Targets/iOS/SupportingFiles/Config/Firebase/GoogleService-Info.plist"
The projects default UI framework is UIKit. But you can easily opt out and use SwiftUI instead. There is no strict rule to use one or the other.
There is an issue with
GitKraken
not supporting theconfig.hooksPath
option. Therefore every hook is copied from the.githooks
directory to.git/hooks
. Before that every file that will be changed inside.git/hooks
is backed up.
This template comes with a .githooks
directory. Inside you can find and create hooks which will run in the local .git
repository.
- commit-msg (run before committing):
- Verifies that the commit message follows the standard Conventional Commits specification
The template uses fastlane for CI/CD. It comes with a nearly empty Fastfile
which can be modified as you wish.
Be sure to run bundle install
first and then execute fastlane through bundle exec
.
bundle exec fastlane tests
create_changelog
: Usegit-chglog
and your conventional commits to automatically create aCHANGELOG.md
in the project directory.git-chglog
uses the template located in.chglog
crowdin
: Use thecrowdin
CLI to upload or download your localisation files