commit e159b2e7526f024c4b8c220b6ddea232ec32d077 Author: Openium <> Date: Fri Dec 10 09:47:55 2021 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0850944 --- /dev/null +++ b/.gitignore @@ -0,0 +1,328 @@ + +# Created by https://www.gitignore.io/api/macos,carthage,symfony,xcode,android,androidstudio +# Edit at https://www.gitignore.io/?templates=macos,carthage,symfony,xcode,android,androidstudio + +### Android ### +# Built application files +*.apk +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +### Android Patch ### +gen-external-apklibs +output.json + +# Replacement of .externalNativeBuild directories introduced +# with Android Studio 3.5. +.cxx/ + +### Carthage ### +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Symfony ### +# Cache and logs (Symfony2) +/app/cache/* +/app/logs/* +!app/cache/.gitkeep +!app/logs/.gitkeep + +# Email spool folder +/app/spool/* + +# Cache, session files and logs (Symfony3) +/var/cache/* +/var/logs/* +/var/sessions/* +!var/cache/.gitkeep +!var/logs/.gitkeep +!var/sessions/.gitkeep + +# Logs (Symfony4) +/var/log/* +!var/log/.gitkeep + +# Parameters +/app/config/parameters.yml +/app/config/parameters.ini + +# Managed by Composer +/app/bootstrap.php.cache +/var/bootstrap.php.cache +/bin/* +!bin/console +!bin/symfony_requirements +/vendor/ + +# Assets and user uploads +/web/bundles/ +/web/uploads/ + +# PHPUnit +/app/phpunit.xml +/phpunit.xml + +# Build data +/build/ + +# Composer PHAR +/composer.phar + +# Backup entities generated with doctrine:generate:entities command +**/Entity/*~ + +# Embedded web-server pid file +/.web-server-pid + +### Symfony Patch ### +/web/css/ +/web/js/ + +### Xcode ### +# Xcode +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## User settings +xcuserdata/ + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) +*.xcscmblueprint +*.xccheckout + +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) +DerivedData/ +*.moved-aside +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 + +## Xcode Patch +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcodeproj/xcshareddata/ +!*.xcworkspace/contents.xcworkspacedata +/*.gcno + +### Xcode Patch ### +**/xcshareddata/WorkspaceSettings.xcsettings + +### AndroidStudio ### +# Covers files to be ignored for android development using Android Studio. + +# Built application files + +# Files for the ART/Dalvik VM + +# Java class files + +# Generated files + +# Gradle files +.gradle + +# Signing files +.signing/ + +# Local configuration file (sdk path, etc) + +# Proguard folder generated by Eclipse + +# Log Files + +# Android Studio +/*/build/ +/*/local.properties +/*/out +/*/*/build +/*/*/production +*.ipr +*~ +*.swp + +# Android Patch + +# External native build folder generated in Android Studio 2.2 and later + +# NDK +obj/ + +# IntelliJ IDEA +*.iws +/out/ + +# User-specific configurations +.idea/caches/ +.idea/libraries/ +.idea/shelf/ +.idea/.name +.idea/compiler.xml +.idea/copyright/profiles_settings.xml +.idea/encodings.xml +.idea/misc.xml +.idea/scopes/scope_settings.xml +.idea/vcs.xml +.idea/jsLibraryMappings.xml +.idea/datasources.xml +.idea/dataSources.ids +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml + +# OS-specific files +.DS_Store? +ehthumbs.db +Thumbs.db + +# Legacy Eclipse project files +.classpath +.project +.cproject +.settings/ + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.war +*.ear + +# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) +hs_err_pid* + +## Plugin-specific files: + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Mongo Explorer plugin +.idea/mongoSettings.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### AndroidStudio Patch ### + +!/gradle/wrapper/gradle-wrapper.jar + +# End of https://www.gitignore.io/api/macos,carthage,symfony,xcode,android,androidstudio diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..d09d0d3 --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,43 @@ +disabled_rules: # rule identifiers to exclude from running + - leading_whitespace + - trailing_whitespace + - identifier_name + - large_tuple + - file_length + - line_length + - force_try + - shorthand_operator + - type_body_length + - function_body_length + - function_parameter_count + - redundant_string_enum_value + - unused_closure_parameter + - cyclomatic_complexity + - syntactic_sugar + - empty_enum_arguments + - force_cast + - multiple_closures_with_trailing_closure + - private_over_fileprivate + - trailing_comma + - comment_spacing +excluded: # paths to ignore during linting. Takes precedence over `included`. + - DerivedData + - Carthage + - Pods + - vendor + - Vendor + - "*/R2Tag+tags.swift" +type_name: + min_length: 1 # only warning + max_length: # warning and error + warning: 50 + error: 60 + allowed_symbols: ["_"] +nesting: + type_level: + warning: 3 + error: 6 + statement_level: + warning: 5 + error: 10 + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..72e3771 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,6 @@ +library "openiumpipeline" + +//env.DEVELOPER_DIR="/Applications/Xcode_12.4.app/Contents/Developer" +//env.SIMULATOR_DEVICE_TYPES="iPad--7th-generation-" + +iOSpipeline() diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/scripts/carthage-check-llvm-prof.sh b/scripts/carthage-check-llvm-prof.sh new file mode 100755 index 0000000..1b2ea71 --- /dev/null +++ b/scripts/carthage-check-llvm-prof.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# https://developer.apple.com/library/content/qa/qa1964/_index.html#//apple_ref/doc/uid/DTS40017675-CH1-SOURCECODE2 + +for fmk in $(find Carthage/Build -type f -perm -a=x) ; do + echo $fmk && nm -m -arch all $fmk | grep __llvm_prf + +done + diff --git a/scripts/carthage-update.sh b/scripts/carthage-update.sh new file mode 100755 index 0000000..cdd77cd --- /dev/null +++ b/scripts/carthage-update.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +export PATH=~/scripts/fakeswiftlint:$PATH + +carthage update $1 --platform iOS --no-use-binaries --no-build --use-submodules + +# https://github.com/Carthage/Carthage/issues/2056 & https://stackoverflow.com/questions/46160518/xcode-9-carthage-itunes-connect-error-invalid-bundle-disallowed-llvm-instr +#find Carthage -type f -name "*.xcscheme" -print0 | xargs -0 perl -pi -e 's/codeCoverageEnabled = "YES"/codeCoverageEnabled = "NO"/g' + +carthage build $1 --platform iOS --no-use-binaries --cache-builds diff --git a/scripts/iconVersioning.sh b/scripts/iconVersioning.sh new file mode 100755 index 0000000..01265fd --- /dev/null +++ b/scripts/iconVersioning.sh @@ -0,0 +1,189 @@ +#!/bin/sh + +if [[ "$BUILD_DIR" == *"IBDesignables"* ]] || [[ "$BUILD_DIR" == *"Previews"* ]] ; then + echo "do nothing when building for IBDesignables/SwiftUI Previews builds"; + exit 0 +fi + +if [ "$CONFIGURATION" != "Release" ]; then +# if [ "$(whoami)" == "hudson" ] || [ "$(whoami)" == "jenkins" ]; then + export PATH=/opt/local/bin/:/opt/local/sbin:$PATH:/usr/local/bin: + + convertPath=`which convert` + gsPath=`which gs` + + if [[ ! -f ${convertPath} || -z ${convertPath} ]]; then + convertValidation=true; + else + convertValidation=false; + fi + + if [[ ! -f ${gsPath} || -z ${gsPath} ]]; then + gsValidation=true; + else + gsValidation=false; + fi + + if [[ "$convertValidation" = true || "$gsValidation" = true ]]; then + echo "WARNING: Skipping Icon versioning, you need to install ImageMagick and ghostscript (fonts) first, you can use brew to simplify process:" + + if [[ "$convertValidation" = true ]]; then + echo "brew install imagemagick" + fi + if [[ "$gsValidation" = true ]]; then + echo "brew install ghostscript" + fi + exit 0; + fi + + if [[ -z "$MARKETING_VERSION" ]] ; then + version="$MARKETING_VERSION" + else + version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${INFOPLIST_FILE}") + fi + build_num=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}") + + # Check if we are under a Git repo + if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then + commit=`git rev-parse --short HEAD` + branch=`git rev-parse --abbrev-ref HEAD` + else + # Check if we are under a Git repo + + svn info >/dev/null 2>&1 + if [ $? -eq 0 ]; then + commit=`svnversion -n` + branch=`svn info | grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$'` + fi + fi; + + #SRCROOT=.. + #CONFIGURATION_BUILD_DIR=. + #UNLOCALIZED_RESOURCES_FOLDER_PATH=. + + #commit="3783bab" + #branch="master" + #version="3.4" + #build_num="9999" + + shopt -s extglob + build_num="${build_num##*( )}" + shopt -u extglob + version_caption="${version}-dev" + if [ ! -z $HUMANVERSION ] ; then + version_caption="$HUMANVERSION" + fi + caption="$version_caption\nr${commit}" + echo $caption + + function abspath() { pushd . > /dev/null; if [ -d "$1" ]; then cd "$1"; dirs -l +0; else cd "`dirname \"$1\"`"; cur_dir=`dirs -l +0`; if [ "$cur_dir" == "/" ]; then echo "$cur_dir`basename \"$1\"`"; else echo "$cur_dir/`basename \"$1\"`"; fi; fi; popd > /dev/null; } + + function processIcon() { + base_file=$1 + + cd "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + base_path=`find . -name ${base_file}` + + real_path=$( abspath "${base_path}" ) + echo "base path ${real_path}" + + if [[ ! -f ${base_path} || -z ${base_path} ]]; then + return; + fi + + # TODO: if they are the same we need to fix it by introducing temp + target_file=`basename $base_path` + target_path="${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${target_file}" + + base_tmp_normalizedFileName="${base_file%.*}-normalized.${base_file##*.}" + base_tmp_path=`dirname $base_path` + base_tmp_normalizedFilePath="${base_tmp_path}/${base_tmp_normalizedFileName}" + + stored_original_file="${base_tmp_normalizedFilePath}-tmp" + if [[ -f ${stored_original_file} ]]; then + echo "found previous file at path ${stored_original_file}, using it as base" + mv "${stored_original_file}" "${base_path}" + fi + + if [ $CONFIGURATION = "Release" ]; then + cp "${base_path}" "$target_path" + return 0; + fi + + echo "Reverting optimized PNG to normal" + # Normalize + echo "xcrun -sdk iphoneos pngcrush -revert-iphone-optimizations -q ${base_path} ${base_tmp_normalizedFilePath}" + xcrun -sdk iphoneos pngcrush -revert-iphone-optimizations -q "${base_path}" "${base_tmp_normalizedFilePath}" + + # move original pngcrush png to tmp file + echo "moving pngcrushed png file at ${base_path} to ${stored_original_file}" + #rm "$base_path" + mv "$base_path" "${stored_original_file}" + + # Rename normalized png's filename to original one + echo "Moving normalized png file to original one ${base_tmp_normalizedFilePath} to ${base_path}" + mv "${base_tmp_normalizedFilePath}" "${base_path}" + + width=`identify -format %w ${base_path}` + height=`identify -format %h ${base_path}` + band_height=$((($height * 47) / 100)) + band_position=$(($height - $band_height)) + text_position=$(($band_position - 3)) + point_size=$(((17 * $width) / 100)) + + echo "Image dimensions ($width x $height) - band height $band_height @ $band_position - point size $point_size" + + # + # blur band and text + # + convert ${base_path} -blur 10x8 /tmp/blurred.png + convert /tmp/blurred.png -gamma 0 -fill white -draw "rectangle 0,$band_position,$width,$height" /tmp/mask.png + convert -size ${width}x${band_height} xc:none -fill 'rgba(0,0,0,0.2)' -draw "rectangle 0,0,$width,$band_height" /tmp/labels-base.png + convert -background none -size ${width}x${band_height} -pointsize $point_size -fill white -gravity center -gravity South caption:"$caption" /tmp/labels.png + + convert ${base_path} /tmp/blurred.png /tmp/mask.png -composite /tmp/temp.png + + # + # compose final image + # + filename=New${base_file} + convert /tmp/temp.png /tmp/labels-base.png -geometry +0+$band_position -composite /tmp/labels.png -geometry +0+$text_position -geometry +${w}-${h} -composite "${target_path}" + + # + # clean up + # + rm /tmp/temp.png + rm /tmp/labels-base.png + rm /tmp/labels.png + rm /tmp/blurred.png + rm /tmp/mask.png + + echo "Overlayed ${target_path}" + } + + icon_count=`/usr/libexec/PlistBuddy -c "Print CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles" "${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}" | wc -l` + last_icon_index=$((${icon_count} - 2)) + + i=0 + while [ $i -lt $last_icon_index ]; do + icon=`/usr/libexec/PlistBuddy -c "Print CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles:$i" "${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}"` + + if [[ $icon == *.png ]] || [[ $icon == *.PNG ]] + then + processIcon $icon + else + processIcon "${icon}.png" + processIcon "${icon}@2x.png" + processIcon "${icon}@3x.png" + fi + let i=i+1 + done + + # Workaround to fix issue#16 to use wildcard * to actually find the file + # Only 72x72 and 76x76 that we need for ipad app icons + processIcon "AppIcon72x72~ipad*" + processIcon "AppIcon72x72@2x~ipad*" + processIcon "AppIcon76x76~ipad*" + processIcon "AppIcon76x76@2x~ipad*" +# fi +fi diff --git a/scripts/lizard.sh b/scripts/lizard.sh new file mode 100755 index 0000000..f7dd8bc --- /dev/null +++ b/scripts/lizard.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +if [[ "$BUILD_DIR" == *"IBDesignables"* ]] || [[ "$BUILD_DIR" == *"Previews"* ]] ; then + echo "do nothing when building for IBDesignables/SwiftUI Previews builds"; + exit 0 +fi + +set -e + +export PATH=$PATH:/usr/local/bin/ +command -v lizard >/dev/null 2>&1 || { echo >&2 "warning: You have to install lizard (see https://github.com/terryyin/lizard). Aborting."; exit 0; } + +lizard -w -x "./Carthage/*" -x "./vendor/*" --CCN 12 --ignore_warnings 20 --working_threads 4 diff --git a/scripts/objc-clean.sh b/scripts/objc-clean.sh new file mode 100755 index 0000000..846e84e --- /dev/null +++ b/scripts/objc-clean.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +if [[ "$BUILD_DIR" == *"IBDesignables"* ]] || [[ "$BUILD_DIR" == *"Previews"* ]] ; then + echo "do nothing when building for IBDesignables/SwiftUI Previews builds"; + exit 0 +fi + +set -e + +if [[ -z ${SKIP_OBJCLEAN} || ${SKIP_OBJCLEAN} != 1 ]]; then + if [[ -d "${LOCAL_APPS_DIR}/Objective-Clean.app" ]]; then + "${LOCAL_APPS_DIR}"/Objective-Clean.app/Contents/Resources/ObjClean.app/Contents/MacOS/ObjClean "${PROJECT_DIR}"?!vendor + else + echo "warning: You have to install and set up Objective-Clean to use its features!" + fi +fi diff --git a/scripts/post-build.sh b/scripts/post-build.sh new file mode 100755 index 0000000..49aa89c --- /dev/null +++ b/scripts/post-build.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +${PROJECT_DIR}/scripts/swiftlint.sh + +${PROJECT_DIR}/scripts/lizard.sh + diff --git a/scripts/resgen.sh b/scripts/resgen.sh new file mode 100755 index 0000000..9a728ab --- /dev/null +++ b/scripts/resgen.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [[ "$BUILD_DIR" == *"IBDesignables"* ]] || [[ "$BUILD_DIR" == *"Previews"* ]] || [[ $ACTION == "install" ]] ; then + echo "do nothing when building for IBDesignables/SwiftUI Previews/archive builds"; + exit 0 +fi + +set -e + +find ${PROJECT_DIR}/resgen -name '*.txt' -exec touch {} \; +echo >&2 "`basename $0`:6: error: Touched all resgen txt files, configure all variables in resgen scripts" && exit 12 + +# Colors +${PROJECT_DIR}/resgen/colors/colors-ios-swift.sh + +# Translations +${PROJECT_DIR}/resgen/twine/twine-ios.sh + +# Images +${PROJECT_DIR}/resgen/images/images-ios-swift.sh + +# Secure +${PROJECT_DIR}/resgen/secure/secure-ios-swift.sh + +# Tags +${PROJECT_DIR}/resgen/tags/tags-ios.sh + diff --git a/scripts/screenshots.sh b/scripts/screenshots.sh new file mode 100755 index 0000000..5c7989c --- /dev/null +++ b/scripts/screenshots.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +#set -x +set -e +# https://github.com/plu/parallel_ios_tests + +# Add this command line arg to your scheme : ${COMMANDLINE_APP_ARGUMENTS} +# To have a list of available devicetypes : +# xcrun simctl list devicetypes +echo "set devicetypes/languages/scheme(s) before launching this script" ; exit 12 +declare -a devicetypes=("iPhone-4s" "iPhone-5" "iPhone-6" "iPhone-6-Plus") +declare -a languages=("fr" "en") +declare -a schemes=("TODO") + +for scheme in "${schemes[@]}"; do + xcodebuild build -sdk iphonesimulator -scheme $scheme -derivedDataPath ./DerivedData ONLY_ACTIVE_ARCH=NO RUN_CLANG_STATIC_ANALYZER=NO VALID_ARCHS="i386 x86_64" ARCHS="i386 x86_64" | xcpretty +done + +echo "Finished initial project compilation" + +## now loop through the devices / langs / schemes (e.g. apps) +for device in "${devicetypes[@]}"; do + set +e + xcrun simctl shutdown screenshot_$device + xcrun simctl delete screenshot_$device + set -e + RUNTIME=$(xcrun simctl list runtimes | grep "com.apple.CoreSimulator.SimRuntime.iOS" | awk '{print $NF}') + UDID=$(xcrun simctl create screenshot_$device com.apple.CoreSimulator.SimDeviceType.$device $RUNTIME) + + for lang in "${languages[@]}"; do + for scheme in "${schemes[@]}"; do + COMMANDLINE_APP_ARGUMENTS="-AppleLanguages ($lang)" xcodebuild test -scheme $scheme -destination name="screenshot_$device" -derivedDataPath ./DerivedData -only-testing:OTKTestAppTests/OTKScreenshotsTests RUN_CLANG_STATIC_ANALYZER=NO | xcpretty + mkdir -p screenshots/${scheme}_$lang/$device + mv /tmp/${scheme}*.jpg screenshots/${scheme}_$lang/$device/ + done + done + + set +e + xcrun simctl shutdown screenshot_$device + xcrun simctl delete screenshot_$device + set -e +done diff --git a/scripts/swiftlint.sh b/scripts/swiftlint.sh new file mode 100755 index 0000000..2073a5d --- /dev/null +++ b/scripts/swiftlint.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# Go to git repo root level +cd $(git rev-parse --show-toplevel) + +if [[ "$BUILD_DIR" == *"IBDesignables"* ]] || [[ "$BUILD_DIR" == *"Previews"* ]] ; then + echo "not linting for IBDesignables/SwiftUI Previews builds"; + exit 0 +fi + +SWIFT_LINT=$(which swiftlint) + +if [[ -z $SWIFT_LINT ]] ; then + echo "warning: SwiftLint not installed, please download it from https://github.com/realm/SwiftLint" + exit 0 +fi + +if [[ $RUN_CLANG_STATIC_ANALYZER == "YES" ]] ; then + time $SWIFT_LINT +else + COUNT=0 + + ##### Check for modified git files ##### + FILES=$(git diff --name-only | grep -iv "^carthage" | grep -iv "^pods" | grep -iv "^vendor" | grep -v "R2" | grep ".swift$") + if [ ! -z "$FILES" ]; then + while read FILE_PATH; do + export SCRIPT_INPUT_FILE_$COUNT=$FILE_PATH + COUNT=$((COUNT + 1)) + done <<< "$FILES" + fi + + ##### Check for modified files in unstaged/Staged area ##### + FILES=$(git diff --name-only --cached --diff-filter=d | grep -iv "^carthage" | grep -iv "^pods" | grep -iv "^vendor" | grep -v "R2" | grep ".swift$") + if [ ! -z "$FILES" ]; then + while read FILE_PATH; do + export SCRIPT_INPUT_FILE_$COUNT=$FILE_PATH + COUNT=$((COUNT + 1)) + done <<< "$FILES" + fi + + ##### Make the count avilable as global variable ##### + export SCRIPT_INPUT_FILE_COUNT=$COUNT + env | grep SCRIPT_INPUT_FILE_ + + if [[ COUNT -ne 0 ]] ; then + time $SWIFT_LINT --use-script-input-files + fi +fi diff --git a/scripts/swiftly-clean.sh b/scripts/swiftly-clean.sh new file mode 100755 index 0000000..60000f6 --- /dev/null +++ b/scripts/swiftly-clean.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +if [[ "$BUILD_DIR" == *"IBDesignables"* ]] || [[ "$BUILD_DIR" == *"Previews"* ]] ; then + echo "do nothing when building for IBDesignables/SwiftUI Previews builds"; + exit 0 +fi + +if [[ -z ${SKIP_SWIFTCLEAN} || ${SKIP_SWIFTCLEAN} != 1 ]]; then + if [[ -d "${LOCAL_APPS_DIR}/Swiftly-Clean.app" ]]; then + "${LOCAL_APPS_DIR}"/Swiftly-Clean.app/Contents/Resources/SwiftClean.app/Contents/MacOS/SwiftClean "${SRCROOT}" + else + echo "warning: You have to install and set up Swift-Clean to use its features!" + fi +fi diff --git a/scripts/todo.sh b/scripts/todo.sh new file mode 100755 index 0000000..75163f9 --- /dev/null +++ b/scripts/todo.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +if [[ "$BUILD_DIR" == *"IBDesignables"* ]] || [[ "$BUILD_DIR" == *"Previews"* ]] ; then + echo "do nothing when building for IBDesignables/SwiftUI Previews builds"; + exit 0 +fi + +if [ "${CONFIGURATION}" = "Debug" ]; then + TAGS="TODO:|FIXME:|WARNING:" + echo "searching ${SRCROOT} for ${TAGS}" + find "${SRCROOT}" -type f -name "*.swift" ! -path "${SRCROOT}/vendor/*" ! -path "${SRCROOT}/build/*" ! -path "${SRCROOT}/DerivedData/*" ! -path "${SRCROOT}/Carthage/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/" +fi diff --git a/scripts/version.sh b/scripts/version.sh new file mode 100755 index 0000000..2908433 --- /dev/null +++ b/scripts/version.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +if [[ "$BUILD_DIR" == *"IBDesignables"* ]] || [[ "$BUILD_DIR" == *"Previews"* ]] ; then + echo "do nothing when building for IBDesignables/SwiftUI Previews builds"; + exit 0 +fi + +set -e + +if [[ -z "$MARKETING_VERSION" ]] ; then + VERS="$MARKETING_VERSION" +else + VERS=$(/usr/libexec/PlistBuddy "${INFOPLIST_FILE}" -c "print CFBundleShortVersionString") +fi +REV=$(git rev-parse --short HEAD) +if [ "$?" -eq "0" ] && [ "$CONFIGURATION" == "Debug" ] ; then + REV=$VERS"-"$REV; + if ! git diff-index --quiet HEAD -- ; then + REV="$REV-mod" + fi +else + REV=$VERS; +fi + +TMPFILE=$(mktemp /tmp/version.h.XXXXXXXXXX) + +echo "#define AppVersionString @\"$REV\"" > $TMPFILE + +if [[ ! -e ${PROJECT_DIR}/version.h ]] || [[ ! -z $(diff ${PROJECT_DIR}/version.h $TMPFILE) ]] ; then + mv $TMPFILE ${PROJECT_DIR}/version.h +else + rm $TMPFILE +fi