From bf2ee4072126128bac6f2c6d52fa2a3813c6a2f7 Mon Sep 17 00:00:00 2001 From: Vladimir Makarov Date: Thu, 4 May 2023 21:42:57 +0200 Subject: [PATCH 1/7] `options[:appName]` for `get_google_services_plist_path` used --- xcode/commonFastfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index dd1a933..e95320d 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -146,7 +146,7 @@ private_lane :buildConfiguration do |options| end upload_symbols_to_crashlytics( - gsp_path: get_google_services_plist_path(app_target_folder_name, configuration_type) + gsp_path: get_google_services_plist_path(options[:appName], configuration_type) ) end From e3b688639feb78c9900defa163d868c53bae5504 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Wed, 17 May 2023 16:15:22 +0300 Subject: [PATCH 2/7] update SwiftLint config to support latest 0.52.2 version features --- xcode/.swiftlint.yml | 80 +++++++++++++++------------------ xcode/build_phases/swiftlint.sh | 8 ++-- 2 files changed, 41 insertions(+), 47 deletions(-) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index 55c4b9e..524c6a6 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -15,7 +15,6 @@ opt_in_rules: # idiomatic - - legacy_random - legacy_multiple - pattern_matching_keywords - redundant_nil_coalescing @@ -32,8 +31,12 @@ opt_in_rules: - fatal_error_message - extension_access_modifier - explicit_init - - prefer_zero_over_explicit_init - fallthrough + - unavailable_function + - prefer_zero_over_explicit_init + - discouraged_assert + - discouraged_none_name + - shorthand_optional_binding # style @@ -55,29 +58,45 @@ opt_in_rules: - closure_spacing - closure_end_indentation - prefer_self_type_over_type_of_self + - closure_parameter_position + - comma_inheritance + - self_binding + - prefer_self_in_static_references + - direct_return + - period_spacing # lint - private_action - private_outlet - prohibited_super_call - - unused_import - - unused_declaration - identical_operands - overridden_super_call - unowned_variable_capture + - strong_iboutlet + - lower_acl_than_parent - comment_spacing + - ibinspectable_in_extension + - private_subject + - unhandled_throwing_task # metrics - enum_case_associated_values_count +analyzer_rules: + - capture_variable + - typesafe_array_init + - unused_declaration + - unused_import + excluded: - Carthage - Pods - Generated - "**/Generated" - "**/Resources" + - ".gem" line_length: warning: 128 @@ -109,6 +128,7 @@ identifier_name: - id - ok - URL + - qr - x - y - z @@ -121,30 +141,17 @@ custom_rules: # General - uiwebview_disabled: - included: ".*.swift" - name: "UIWebView Usage Disabled" - regex: 'UIWebView' - message: "Do not use UIWebView. Use WKWebView Instead. https://developer.apple.com/reference/uikit/uiwebview" - severity: error - - native_print: - name: "print -> DDLog" - regex: '(print|NSLog)\(' - message: "Please use CocoaLumberjack instead `print` and `NSlog`" - severity: error - - uiedge_insets_zero: - name: "UIEdgeInsets .zero" - regex: '\(top: 0, left: 0, bottom: 0, right: 0\)' - message: "Please use short init `.zero`." - severity: error - - let_variable: - name: "Let Variable" - regex: 'var\s\w*(:|(\s=))\sVariable' - message: "Please make variable using `let`." + unsecure_logging: + name: "Unsecure logging" + regex: '\s(print|debugPrint|NSLog)\(' + message: "Please use os_log or remove this debug statement" severity: error + excluded_match_kinds: + - comment + - comment.mark + - comment.url + - doccomment + - doccomment.field marks_style: name: "Marks" @@ -165,19 +172,12 @@ custom_rules: message: "Type definition not needed" severity: error - unowned: - name: "Unowned" + unsafe_unowned: + name: "Unsafe unowned usage" regex: 'unowned' - message: "Please use `weak` instead. " + message: "Please use `weak` instead." severity: error - continue_keyword: - name: "Continue" - regex: 'continue' - message: "Don't use continue instruction" - severity: error - match_kinds: keyword - cyrillic_strings: name: "Cyrillic strings" regex: '[а-яА-Я]+' @@ -237,12 +237,6 @@ custom_rules: message: "Use сontentView instead of self for addSubview or addSubviews methods in cell." severity: warning - redundant_type_annotation_bool: - name: "Redundant type annotation for Bool" - regex: '\s((var|let))\s{1,}\w+ *((: *Bool *=)|((\w| |<|>|:)*= *BehaviorRelay\( *value *:)) *((true)|(false))' - message: "Using a type annotation for Bool is redundant." - severity: warning - parameter_repetition: name: "Parameter repetition" regex: 'func ((\w+([A-Z]\w+))|(\w+)) *(<[^>]+>)? *\( *(?i)(\3|\4):' diff --git a/xcode/build_phases/swiftlint.sh b/xcode/build_phases/swiftlint.sh index 887866a..16abdc1 100755 --- a/xcode/build_phases/swiftlint.sh +++ b/xcode/build_phases/swiftlint.sh @@ -46,8 +46,8 @@ fi if [ ! -z "${FORCE_LINT}" ]; then # Если задана переменная FORCE_LINT, то проверяем все файлы проекта for SOURCE_DIR in ${SOURCES_DIRS}; do - ${SWIFTLINT_EXECUTABLE} autocorrect --path ${SOURCE_DIR} --config ${SWIFTLINT_CONFIG_PATH} - ${SWIFTLINT_EXECUTABLE} --path ${SOURCE_DIR} --config ${SWIFTLINT_CONFIG_PATH} + ${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} --fix --format ${SOURCE_DIR} + ${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} ${SOURCE_DIR} done else # Xcode упадет, если будем использовать большое количество Script Input Files, @@ -81,6 +81,6 @@ else swiftlint_files_path="@${lint_files_path}" - ${SWIFTLINT_EXECUTABLE} autocorrect --path ${swiftlint_files_path} --config ${SWIFTLINT_CONFIG_PATH} --force-exclude --use-alternative-excluding - ${SWIFTLINT_EXECUTABLE} --path ${swiftlint_files_path} --config ${SWIFTLINT_CONFIG_PATH} --force-exclude --use-alternative-excluding + ${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} --fix --format --force-exclude --use-alternative-excluding ${swiftlint_files_path} + ${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} --force-exclude --use-alternative-excluding ${swiftlint_files_path} fi From b843196f3c9d9eda4ec8eeba29bf5cc859f55f18 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Fri, 19 May 2023 16:41:19 +0300 Subject: [PATCH 3/7] Disable autocorrection by default, make script more independent of environment --- .../common/read_input_file_names.sh | 15 ++++----- xcode/build_phases/swiftlint.sh | 33 +++++++++++++------ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/xcode/build_phases/common/read_input_file_names.sh b/xcode/build_phases/common/read_input_file_names.sh index 8d3f543..7de9439 100644 --- a/xcode/build_phases/common/read_input_file_names.sh +++ b/xcode/build_phases/common/read_input_file_names.sh @@ -62,16 +62,13 @@ if has_input_files && \ SHELL_VARIABLE="\${${SCRIPT_INPUT_FILE_VARIABLE_NAME}}" RESOLVED_FILE_NAME=`envsubst <<< ${SHELL_VARIABLE}` INPUT_FILE_NAMES=${INPUT_FILE_NAMES}${FILE_NAMES_SEPARATOR}${RESOLVED_FILE_NAME} + + if [ ! -z ${INPUT_FILE_NAMES} ]; then + INPUT_FILE_NAMES=${INPUT_FILE_NAMES}${FILE_NAMES_SEPARATOR} + fi + + INPUT_FILE_NAMES=${INPUT_FILE_NAMES}${RESOLVED_FILE_NAME} done - - FILE_NAMES_SEPARATOR_LENGTH=`awk '{ print length; }' <<< "${FILE_NAMES_SEPARATOR}"` - - if [ ${FILE_NAMES_SEPARATOR_LENGTH} -gt 0 ] && \ - [ ! -z "${INPUT_FILE_NAMES}" ]; then - - # remove separator prefix - INPUT_FILE_NAMES=`cut -c${FILE_NAMES_SEPARATOR_LENGTH}- <<< ${INPUT_FILE_NAMES}` - fi elif has_input_file_lists; then for i in `seq 0 $((${SCRIPT_INPUT_FILE_LIST_COUNT}-1))` do diff --git a/xcode/build_phases/swiftlint.sh b/xcode/build_phases/swiftlint.sh index 16abdc1..8f1e5cd 100755 --- a/xcode/build_phases/swiftlint.sh +++ b/xcode/build_phases/swiftlint.sh @@ -2,6 +2,7 @@ # Description: # Runs swiftlint with selected or default config file. +# By default it runs only for modified files. # # Parameters: # $1 - path to swiftlint executable. @@ -10,14 +11,15 @@ # Required environment variables: # SCRIPT_DIR - directory of current script. # SRCROOT - project directory. -# PODS_ROOT - cocoapods installation directory (eg. ${SRCROOT}/Pods). # # Optional environment variables: # SWIFTLINT_EXECUTABLE - path to swiftlint executable. # SWIFTLINT_CONFIG_PATH - path to swiftlint config. +# PODS_ROOT - cocoapods installation directory (eg. ${SRCROOT}/Pods) if SWIFTLINT_EXECUTABLE or ${1} is missing # SCRIPT_INPUT_FILE_COUNT - number of files listed in "Input files" of build phase. # SCRIPT_INPUT_FILE_{N} - file path to directory that should be checked. -# FORCE_LINT - lint all project. +# FORCE_LINT - don't exclude not modified files. +# AUTOCORRECT - format and fix code before lint. # # Example of usage: # swiftlint.sh @@ -46,8 +48,11 @@ fi if [ ! -z "${FORCE_LINT}" ]; then # Если задана переменная FORCE_LINT, то проверяем все файлы проекта for SOURCE_DIR in ${SOURCES_DIRS}; do - ${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} --fix --format ${SOURCE_DIR} - ${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} ${SOURCE_DIR} + if [ ! -z "${AUTOCORRECT}" ]; then + ${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} --fix --format "${SRCROOT}/${SOURCE_DIR}" + fi + + ${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} "${SRCROOT}/${SOURCE_DIR}" done else # Xcode упадет, если будем использовать большое количество Script Input Files, @@ -56,19 +61,24 @@ else # Создадим временный файл swiftlint_files с префиксом @ и в нем уже определим список файлов # необходимых для линтовки :) - lint_files_path="${SRCROOT}/build_phases/swiftlint_files" + lint_files_path="`mktemp -d`/swiftlint_files" # Если файл существует, то просто его очистим, если нет - создадим > ${lint_files_path} # Проходимся по папкам, которые требуют линтовки for SOURCE_DIR in ${SOURCES_DIRS}; do - # Путь к папке репозитория - path_prefix="`git rev-parse --show-toplevel`/" + LINE_PREFIX="${SRCROOT}/" + + pushd . + + cd ${SRCROOT} # in case of runing script outside project folder (SPM) # Отбираем файлы, которые были изменены или созданы - source_unstaged_files=$(git diff --diff-filter=d --name-only --line-prefix=${path_prefix} ${SOURCE_DIR} | grep "\.swift$") - source_staged_files=$(git diff --diff-filter=d --name-only --line-prefix=${path_prefix} --cached ${SOURCE_DIR} | grep "\.swift$") + source_unstaged_files=$(git diff --diff-filter=d --name-only --line-prefix=${LINE_PREFIX} ${SOURCE_DIR} | grep "\.swift$") + source_staged_files=$(git diff --diff-filter=d --name-only --line-prefix=${LINE_PREFIX} --cached ${SOURCE_DIR} | grep "\.swift$") + + popd if [ ! -z "${source_unstaged_files}" ]; then echo "${source_unstaged_files}" >> ${lint_files_path} @@ -81,6 +91,9 @@ else swiftlint_files_path="@${lint_files_path}" - ${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} --fix --format --force-exclude --use-alternative-excluding ${swiftlint_files_path} + if [ ! -z "${AUTOCORRECT}" ]; then + ${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} --fix --format --force-exclude --use-alternative-excluding ${swiftlint_files_path} + fi + ${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} --force-exclude --use-alternative-excluding ${swiftlint_files_path} fi From 7d3f2794bcdbf03c592f864950c1e6ff24e423b5 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Mon, 22 May 2023 11:59:45 +0300 Subject: [PATCH 4/7] simplify temp file creation --- xcode/build_phases/swiftlint.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/xcode/build_phases/swiftlint.sh b/xcode/build_phases/swiftlint.sh index 8f1e5cd..966dec9 100755 --- a/xcode/build_phases/swiftlint.sh +++ b/xcode/build_phases/swiftlint.sh @@ -61,10 +61,7 @@ else # Создадим временный файл swiftlint_files с префиксом @ и в нем уже определим список файлов # необходимых для линтовки :) - lint_files_path="`mktemp -d`/swiftlint_files" - - # Если файл существует, то просто его очистим, если нет - создадим - > ${lint_files_path} + lint_files_path=`mktemp` # Проходимся по папкам, которые требуют линтовки for SOURCE_DIR in ${SOURCES_DIRS}; do From f1fe35d298382128b8d0d7f079ce5e1a64a3f9bc Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Wed, 24 May 2023 13:35:01 +0300 Subject: [PATCH 5/7] exclude playground app from lint, add make gen command to Makefile --- xcode/.swiftlint.yml | 1 + xcode/bootstrap/Makefile | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index 524c6a6..ceee568 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -97,6 +97,7 @@ excluded: - "**/Generated" - "**/Resources" - ".gem" + - "**/*.app" line_length: warning: 128 diff --git a/xcode/bootstrap/Makefile b/xcode/bootstrap/Makefile index 7894911..09940d2 100644 --- a/xcode/bootstrap/Makefile +++ b/xcode/bootstrap/Makefile @@ -8,6 +8,7 @@ RUBY_VERSION="2.7.6" open_project=(open *.xcworkspace) install_dev_certs=(bundle exec fastlane SyncCodeSigning type:development readonly:true) install_pods=(bundle exec pod install || bundle exec pod install --repo-update) +init_rbenv=(if command -v rbenv &> /dev/null; then eval "$$(rbenv init -)"; fi) TARGET_MAX_CHAR_NUM=20 ## Show help @@ -31,7 +32,7 @@ help: init: brew bundle - eval "$(rbenv init -)" + $(call init_rbenv) rbenv install -s ${RUBY_VERSION} rbenv global ${RUBY_VERSION} @@ -43,7 +44,7 @@ init: bundle install - xcodegen + $(call gen) $(call install_pods) @@ -59,6 +60,10 @@ init: pod: $(call install_pods) +## Запускает генерацию файла проекта +gen: + xcodegen + ## Устанавливает сертификат и профили для запуска на девайсе dev_certs: $(call install_dev_certs) From 3e249eae3d1eaeff8f87687256ecc2c0d08ed441 Mon Sep 17 00:00:00 2001 From: Nikita Mikryukov <97m.nik@gmail.com> Date: Mon, 29 May 2023 09:28:27 +0300 Subject: [PATCH 6/7] updated repositories link --- scripts/export_src.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/export_src.sh b/scripts/export_src.sh index 57323dd..77a8876 100755 --- a/scripts/export_src.sh +++ b/scripts/export_src.sh @@ -30,7 +30,7 @@ clone_platform() { PROJECT_NAME=$1 PLATFORM=$2 - if git clone --recurse-submodules -j8 "git@gitlab.ti:touchinstinct/${PROJECT_NAME}-${PLATFORM}.git" --branch "${GIT_BRANCH}"; then + if git clone --recurse-submodules -j8 "https://git.ti/scm/touchinstinct/${PROJECT_NAME}-${PLATFORM}.git" --branch "${GIT_BRANCH}"; then cd ${PROJECT_NAME}-${PLATFORM} COMMIT_DATE=`git log -1 --pretty='format:%cd' --date=format:'%Y-%m-%d'` From c841e48516574a21de75ebb94018709ac8cdec60 Mon Sep 17 00:00:00 2001 From: Nikita Mikryukov <97m.nik@gmail.com> Date: Mon, 29 May 2023 09:55:50 +0300 Subject: [PATCH 7/7] changed https link to ssh --- scripts/export_src.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/export_src.sh b/scripts/export_src.sh index 77a8876..20c12bc 100755 --- a/scripts/export_src.sh +++ b/scripts/export_src.sh @@ -30,7 +30,7 @@ clone_platform() { PROJECT_NAME=$1 PLATFORM=$2 - if git clone --recurse-submodules -j8 "https://git.ti/scm/touchinstinct/${PROJECT_NAME}-${PLATFORM}.git" --branch "${GIT_BRANCH}"; then + if git clone --recurse-submodules -j8 "ssh://git@git.ti:7999/touchinstinct/${PROJECT_NAME}-${PLATFORM}.git" --branch "${GIT_BRANCH}"; then cd ${PROJECT_NAME}-${PLATFORM} COMMIT_DATE=`git log -1 --pretty='format:%cd' --date=format:'%Y-%m-%d'`