-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
72 lines (58 loc) · 1.49 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Configuration variables:
.DEFAULT_GOAL := project
export APP_NAME = TheApp
export BUNDLE_IDENTIFIER = com.new.appIdentifier
# Prepare Application workspace
project:
xcodegen generate
bundle exec pod install
resources:
mkdir -p "Sources/App/SupportingFiles/Generated"
swiftgen config run --config swiftgen.yml
dependencies:
bundle exec pod install --repo-update
update_dependencies:
bundle exec pod update
# Reset the project for a clean build
clean:
rm -rf *.xcodeproj
rm -rf *.xcworkspace
rm -rf Pods/
format:
swiftformat .
swiftlint autocorrect
# Install dependencies, download build resources and add pre-commit hook
setup:
make clean
bundle config set path 'vendor/bundle'
bundle update
# brew update && brew bundle
brew bundle
make git_setup
make resources
# bundle exec pod repo update
make project
git_setup:
eval "$$add_pre_commit_script"
# Define pre commit script to auto lint and format the code
define _add_pre_commit
SWIFTLINT_PATH=`which swiftlint`
SWIFTFORMAT_PATH=`which swiftformat`
if [ -d ".git" ]; then
cat > .git/hooks/pre-commit << ENDOFFILE
#!/bin/sh
FILES=\$(git diff --cached --name-only --diff-filter=ACMR "*.swift" | sed 's| |\\ |g')
[ -z "\$FILES" ] && exit 0
# Format
${SWIFTFORMAT_PATH} \$FILES
# Lint
${SWIFTLINT_PATH} autocorrect \$FILES
${SWIFTLINT_PATH} lint \$FILES
# Add back the formatted/linted files to staging
echo "\$FILES" | xargs git add
exit 0
ENDOFFILE
chmod +x .git/hooks/pre-commit
fi
endef
export add_pre_commit_script = $(value _add_pre_commit)