diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..b38e7695 --- /dev/null +++ b/.clang-format @@ -0,0 +1,33 @@ +# Basic indentation settings +IndentWidth: 2 +TabWidth: 2 +ContinuationIndentWidth: 4 +UseTab: Never +IndentPPDirectives: BeforeHash + +# Code formatting rules +BreakBeforeBraces: Custom +BraceWrapping: + AfterClass: true + AfterControlStatement: true + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true + IndentBraces: false +ColumnLimit: 300 + +# Blank lines +MaxEmptyLinesToKeep: 1 + +# Alignment +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: true +AlignOperands: true +AlignTrailingComments: true + +# Import statements +SortIncludes: true \ No newline at end of file diff --git a/Package.swift b/Package.swift index 70ecfc6f..10bf0da8 100644 --- a/Package.swift +++ b/Package.swift @@ -36,6 +36,7 @@ let package = Package( "LICENSE", "README.md", "countly_dsym_uploader.sh", + "format.sh", "CHANGELOG.md", "SECURITY.md", "CountlyTests/" diff --git a/format.sh b/format.sh new file mode 100755 index 00000000..a3ee02f3 --- /dev/null +++ b/format.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +CDP=$(osascript -e ' +tell application "Xcode" + activate + --wait for Xcode to remove edited flag from filename + delay 0.3 + set last_word_in_main_window to (word -1 of (get name of window 1)) + set current_document to document 1 whose name ends with last_word_in_main_window + set current_document_path to path of current_document + --CDP is assigned last set value: current_document_path +end tell ') + +sleep 0.6 ### during save Xcode stops listening for file changes +/usr/local/bin/clang-format -style=file -i ${CDP} + +# EOF