diff --git a/scripts/export_src.sh b/scripts/export_src.sh index 57323dd..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 "git@gitlab.ti: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'` diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index 55c4b9e..ceee568 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,46 @@ 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" + - "**/*.app" line_length: warning: 128 @@ -109,6 +129,7 @@ identifier_name: - id - ok - URL + - qr - x - y - z @@ -121,30 +142,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 +173,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 +238,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/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) 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 887866a..966dec9 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} autocorrect --path ${SOURCE_DIR} --config ${SWIFTLINT_CONFIG_PATH} - ${SWIFTLINT_EXECUTABLE} --path ${SOURCE_DIR} --config ${SWIFTLINT_CONFIG_PATH} + 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,21 @@ else # Создадим временный файл swiftlint_files с префиксом @ и в нем уже определим список файлов # необходимых для линтовки :) - lint_files_path="${SRCROOT}/build_phases/swiftlint_files" - - # Если файл существует, то просто его очистим, если нет - создадим - > ${lint_files_path} + lint_files_path=`mktemp` # Проходимся по папкам, которые требуют линтовки 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 +88,9 @@ 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 + 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 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