Skip to content

Commit 48082a1

Browse files
authored
Merge pull request #114 from smartmobilefactory/drstring-integration
Drstring integration
2 parents 2b9c9f1 + f3290d0 commit 48082a1

6 files changed

Lines changed: 77 additions & 7 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
# Copies the DrString configuration to the projects base folder
3+
#
4+
# Author Pierre Rothmaler
5+
#
6+
# Last revised 23/09/2020
7+
8+
#
9+
# Constants
10+
#
11+
12+
readonly scriptBaseFolderPath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
13+
14+
#
15+
# Variables
16+
#
17+
18+
projectDir="$1"
19+
20+
#
21+
# Check requirements
22+
#
23+
24+
# Check if project directory is provided. If not: Use the scripts base directory.
25+
if [ -z "$1" ]; then
26+
projectDir="$scriptBaseFolderPath"
27+
fi
28+
29+
#
30+
# Logic
31+
#
32+
33+
# Go the folder which contains this script
34+
cd "$scriptBaseFolderPath"
35+
36+
# Copy the DrString file to the projects base folder
37+
cp "drstring.toml" "$projectDir/.drstring.toml"
38+
39+
# Go to the project folder and run DrString from there
40+
cd "$projectDir"
41+
42+
DRSTRING_EXECUTABLE="$scriptBaseFolderPath/drstring"
43+
44+
if [ -f "$DRSTRING_EXECUTABLE" ]; then
45+
"$DRSTRING_EXECUTABLE" check --config-file $projectDir/.drstring.toml || true
46+
else
47+
echo "warning: DrString not installed."
48+
exit 1
49+
fi

DrString/drstring

12.4 MB
Binary file not shown.

DrString/drstring.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include = [
2+
'Core/**/*.swift',
3+
]
4+
5+
ignore-throws = true
6+
ignore-returns = true

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SMF-iOS-CommonProjectSetupFiles
22

3-
[![Language: Swift 3.1](https://img.shields.io/badge/Swift-3.1-orange.svg)](https://swift.org)
4-
[![Xcode: Xcode 8.3.3](https://img.shields.io/badge/Xcode-8.3.3-orange.svg)](https://swift.org)
3+
[![Language: Swift 5.3](https://img.shields.io/badge/Swift-5.2-orange.svg)](https://swift.org)
4+
[![Xcode: Xcode 11.7](https://img.shields.io/badge/Xcode-11.7-orange.svg)](https://developer.apple.com/xcode)
55

66
This Repo contains our common project setup files.
77

@@ -15,6 +15,7 @@ Helpers which can be added manually to the Xcode project which should be used:
1515
Scripts which should be called during the build phase:
1616

1717
- [SwiftLint](#swiftlint)
18+
- [DrSwift](#drswift)
1819
- [Xcode version check](#xcode-version-check)
1920

2021
### Setup
@@ -166,13 +167,13 @@ Multiple `#if canImport(LifetimeTracker)` checks make sure that targets with Lif
166167

167168
Swiftlint is integrated in SMF-iOS-CommonProjectSetupFiles itself. The current version is 0.28.1.
168169

169-
### Integrate it into the project
170+
#### Integrate it into the project
170171

171-
**Make sure that `/.swiftlint.yml` is added to the gitignore file as the this default SwiftLint configuration file be automatically copied from the repo into the projects base folder.**
172+
**Make sure that `/.swiftlint.yml` is added to the gitignore file as the default SwiftLint configuration file be automatically copied from the repo into the projects base folder.**
172173

173174
The Swiftlint configuration and lint call is integrated in the [setup script](#setup). If it shouldn't be used you can pass the flag `--no-swiftlint`.
174175

175-
#### Excluded files from litting
176+
##### Excluded files from litting
176177

177178
You can declare excluded paths in the project specific swiftlint configuration file `.project-swiftlint.yml`. The file has to be placed in the same directoy as the copied `.swiftlint.yml` (usually the project root directory). The scripts *setup-common-project-files.sh* and *copy-and-run-swiftlint-config.sh* are automatically using the `.project-swiftlint.yml` file if it exists.
178179

@@ -183,9 +184,19 @@ excluded:
183184
- App/HiDrive/Generated
184185
```
185186

186-
#### Optional: Call the SwiftLint script without using the setup script
187+
##### Optional: Call the SwiftLint script without using the setup script
187188
If you want to copy the SwiftLint configuration and lint the code without integrating the setup script you can call `Submodules/SMF-iOS-CommonProjectSetupFiles/SwiftLint/copy-and-run-swiftlint-config.sh` directly.
188189

190+
### DrSwift
191+
192+
[DrSwift](https://github.com/dduan/DrString) is integrated in SMF-iOS-CommonProjectSetupFiles itself. The current version is 0.4.2.
193+
194+
#### Integrate it into the project
195+
196+
DrString is configured to run when you execute `Submodules/SMF-iOS-CommonProjectSetupFiles/setup-common-project-files.sh` with [framework target configuration](#setup) parameters.
197+
198+
**Make sure that `/.drstring.toml` is added to the gitignore file as the DrSwift configuration file be automatically copied from the repo into the projects base folder.**
199+
189200
### Xcode version check
190201

191202
Building a project will trigger a Xcode version check to ensure you are working with the right Xcode version and an updated `smf.properties`. This script will look for the Xcode version specified in `smf.properties`. It will compare it to the Xcode version you are currently building the project and throw an error if it does not match.

SwiftLint/copy-and-run-swiftlint-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copies the Swiflint configuration to the projects base folder
2+
# Copies the Swiftlint configuration to the projects base folder
33
#
44
# Author Hans Seiffert
55
# Updated Kevin Delord

setup-common-project-files.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ if [ $callSwiftlint = true ]; then
130130
./SwiftLint/copy-and-run-swiftlint-config.sh "$projectDir" $isFramework $isSwiftUIProject || exit 1;
131131
fi
132132

133+
if [ $isFramework = true ]; then
134+
./DrString/copy-and-run-DrString-config.sh "$projectDir" || exit 1;
135+
fi
136+
133137
if [ $copyPRTemplate = true ]; then
134138

135139
mkdir -p "$projectDir/.github"

0 commit comments

Comments
 (0)