Build PhasesNew Run Script Phaseを追加して以下のコードをコピーしてビルドするだけ

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
if [ ! -e .swiftformat ]; then
touch .swiftformat
fi

if [ "${CONFIGURATION}" = "Debug" ] && [ "${ENABLE_PREVIEWS}" = "NO" ]; then
if [ ! -e swiftformat.0.53.1 ]; then
curl -OL https://github.com/nicklockwood/SwiftFormat/releases/download/0.53.1/swiftformat.zip
unzip swiftformat.zip
mv swiftformat swiftformat.0.53.1
rm swiftformat.zip
fi

./swiftformat.0.53.1 --cache ignore --swiftversion 5.9 .
else
echo "swiftformat in skipped"
fi

if [ ! -e .swiftlint.yml ]; then
touch .swiftlint.yml
fi

if [ "${CONFIGURATION}" = "Debug" ] && [ "${ENABLE_PREVIEWS}" = "NO" ]; then
if [ ! -e swiftlint.0.54.0 ]; then
curl -OL https://github.com/realm/SwiftLint/releases/download/0.54.0/portable_swiftlint.zip
unzip portable_swiftlint.zip swiftlint
mv swiftlint swiftlint.0.54.0
rm portable_swiftlint.zip
fi

./swiftlint.0.54.0 --no-cache
else
echo "swiftlint in skipped"
fi

もし権限エラー発生時はBuild SettingsENABLE_USER_SCRIPT_SANDBOXINGNOに設定

touch: .swiftformat: Operation not permitted