From c64434026cfdb6e13f04845a198187b25c3f0057 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Wed, 21 Jul 2021 14:29:04 +0300 Subject: [PATCH] update template project --- bootstrap.sh | 13 ++--- foldernames.txt | 2 +- sources/Brewfile | 7 +-- sources/Gemfile | 1 + sources/build_phases/install_env.sh | 13 +++++ sources/fastlane/Pluginfile | 1 + sources/package.json | 5 -- sources/project/AppDelegate.swift | 3 +- .../Firebase/FirebaseConfigurator.swift | 31 ----------- .../project/Services/NavigationService.swift | 7 --- templates/Podfile.mustache | 15 +----- templates/gitignore | 4 +- templates/project.mustache | 53 +++++++++++++------ 13 files changed, 66 insertions(+), 89 deletions(-) create mode 100755 sources/build_phases/install_env.sh delete mode 100644 sources/package.json delete mode 100644 sources/project/Models/Firebase/FirebaseConfigurator.swift delete mode 100644 sources/project/Services/NavigationService.swift diff --git a/bootstrap.sh b/bootstrap.sh index ac26811..9fdfcef 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -8,7 +8,7 @@ function generate { RESULT_PATH=$3 echo $PARAMS > data.yml - mustache data.yml $TEMPLATE_PATH > $RESULT_PATH + bundle exec mustache data.yml $TEMPLATE_PATH > $RESULT_PATH rm data.yml } @@ -17,7 +17,7 @@ readonly PROJECTS_PATH=$1 readonly PROJECT_NAME=$2 readonly PROJECT_NAME_WITH_PREFIX=$2-ios readonly COMMON_REPO_NAME=${3:-$2-common} -readonly DEPLOYMENT_TARGET="12.0" +readonly DEPLOYMENT_TARGET="13.0" readonly CURRENT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) readonly TEMPLATES=$CURRENT_DIR/templates readonly MATCH_PASSWORD=`pwgen 8 1` @@ -60,7 +60,6 @@ done # install required gems & brews cp $CURRENT_DIR/sources/Gemfile Gemfile -cp $CURRENT_DIR/sources/Gemfile.lock Gemfile.lock cp $CURRENT_DIR/sources/Brewfile Brewfile gem install bundler @@ -138,7 +137,7 @@ generate "{project_name: $PROJECT_NAME}" $TEMPLATES/README.mustache README.md git submodule add git@github.com:TouchInstinct/$COMMON_REPO_NAME.git common git submodule add git@github.com:TouchInstinct/BuildScripts.git build-scripts -git submodule update --init +git submodule update --init --recursive --remote # final clean up rm project.yml @@ -147,12 +146,6 @@ rm project.yml cp $CURRENT_DIR/additional/Brewfile Brewfile brew bundle -#copy package for firebase -cp $CURRENT_DIR/sources/package.json package.json - -#yarn -yarn install - # copy setup, install and update commands cp $CURRENT_DIR/sources/setup.command setup.command cp $CURRENT_DIR/sources/install_dependencies.command install_dependencies.command diff --git a/foldernames.txt b/foldernames.txt index 354474a..7690d9c 100644 --- a/foldernames.txt +++ b/foldernames.txt @@ -2,7 +2,7 @@ Analytics Cells Controllers Extensions -Generated +../Generated Networking Protocols Resources/Localization diff --git a/sources/Brewfile b/sources/Brewfile index e6e18be..bc8042d 100644 --- a/sources/Brewfile +++ b/sources/Brewfile @@ -1,3 +1,4 @@ -tap "yonaskolb/XcodeGen", "https://github.com/yonaskolb/XcodeGen.git" - -brew "XcodeGen" +brew "imagemagick" +brew "pmd" +brew "xcodegen" +brew "gettext" \ No newline at end of file diff --git a/sources/Gemfile b/sources/Gemfile index acd778b..33d3940 100644 --- a/sources/Gemfile +++ b/sources/Gemfile @@ -4,6 +4,7 @@ git_source(:github) { |repo| "https://github.com/strongself/Generamba.git" } gem "cocoapods" gem "fastlane" gem 'generamba', github: 'strongself/develop' +gem "mustache" plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/sources/build_phases/install_env.sh b/sources/build_phases/install_env.sh new file mode 100755 index 0000000..65b8353 --- /dev/null +++ b/sources/build_phases/install_env.sh @@ -0,0 +1,13 @@ +# When you run Git from the command line, it runs in the environment as set up by your Shell. +# GUI OS X apps, however, have no knowledge about your shell - and the PATH environment can be changed in many different places. +# Export our profile with path by ourselves + +function source_home_file { + file="$HOME/$1" + [[ -f "${file}" ]] && source "${file}" +} + +# Use specific exec due to Xcode has custom value of $PATH +if [ -z "$(which pmd)" ]; then + source_home_file ".bash_profile" || source_home_file ".zshrc" || true +fi \ No newline at end of file diff --git a/sources/fastlane/Pluginfile b/sources/fastlane/Pluginfile index 7abf7a5..5a17a9b 100644 --- a/sources/fastlane/Pluginfile +++ b/sources/fastlane/Pluginfile @@ -4,3 +4,4 @@ gem 'fastlane-plugin-firebase_app_distribution' gem 'fastlane-plugin-badge' +gem 'fastlane-plugin-xcodegen' diff --git a/sources/package.json b/sources/package.json deleted file mode 100644 index ced16cd..0000000 --- a/sources/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "dependencies": { - "firebase-tools": "^7.12.1" - } -} diff --git a/sources/project/AppDelegate.swift b/sources/project/AppDelegate.swift index 9c2d75b..81a9f98 100755 --- a/sources/project/AppDelegate.swift +++ b/sources/project/AppDelegate.swift @@ -1,4 +1,5 @@ import UIKit +import Firebase @UIApplicationMain final class AppDelegate: UIResponder, UIApplicationDelegate { @@ -26,7 +27,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - FirebaseConfigurator.configure() + FirebaseApp.configure() return true } } diff --git a/sources/project/Models/Firebase/FirebaseConfigurator.swift b/sources/project/Models/Firebase/FirebaseConfigurator.swift deleted file mode 100644 index ef0b5b1..0000000 --- a/sources/project/Models/Firebase/FirebaseConfigurator.swift +++ /dev/null @@ -1,31 +0,0 @@ -import Firebase - -enum FirebaseConfigurator { - - private static var resourceName: String { - #if APPSTORE - return "AppStore-GoogleService-Info" - #elseif ENTERPRISE - return "Enterprise-GoogleService-Info" - #elseif STANDARD - return "Standard-GoogleService-Info" - #else - assertionFailure("There is no right plist file") - return .empty - #endif - } - - static func configure() { - guard let filePath = Bundle.main.path(forResource: resourceName, ofType: .fileExtension), - let options = FirebaseOptions(contentsOfFile: filePath) else { - return - } - - FirebaseApp.configure(options: options) - } -} - -// MARK: - Constants -private extension String { - static let fileExtension = "plist" -} diff --git a/sources/project/Services/NavigationService.swift b/sources/project/Services/NavigationService.swift deleted file mode 100644 index 82a79b6..0000000 --- a/sources/project/Services/NavigationService.swift +++ /dev/null @@ -1,7 +0,0 @@ -import UIKit - -enum NavigationService { - static var appWindow: UIWindow { - return AppDelegate.shared.appWindow - } -} diff --git a/templates/Podfile.mustache b/templates/Podfile.mustache index 6e1d7f1..9829e25 100755 --- a/templates/Podfile.mustache +++ b/templates/Podfile.mustache @@ -1,5 +1,5 @@ source 'https://cdn.cocoapods.org/' -source 'git@github.com:TouchInstinct/Podspecs' +source 'https://github.com/TouchInstinct/Podspecs.git' platform :ios, '{{deployment_target}}' @@ -21,22 +21,9 @@ target '{{project_name}}' do pod 'Firebase/Performance' pod 'Firebase/Analytics' # for Firebase/Performance - # Rx - pod 'RxKeyboard', '1.0.0' - - # Security - pod 'KeychainAccess' - # Utils - pod 'LeadKit' pod 'DeviceKit' - # Layout - pod 'SnapKit' - - # UI - pod 'TableKit' - end # fixes Xcode 12 warnings: diff --git a/templates/gitignore b/templates/gitignore index 6e6fd26..48b9c26 100755 --- a/templates/gitignore +++ b/templates/gitignore @@ -92,9 +92,9 @@ iOSInjectionProject/ # homebrew-bundle Brewfile.lock.json -# Node.js +# Ruby gems # Dependency directories -node_modules/ +*.gem # Touch Instinct custom Downloads/ diff --git a/templates/project.mustache b/templates/project.mustache index 976c270..7427667 100644 --- a/templates/project.mustache +++ b/templates/project.mustache @@ -2,7 +2,7 @@ name: {{project_name}} options: createIntermediateGroups: true - xcodeVersion: 11.0 + xcodeVersion: 12.2 usesTabs: false indentWidth: 4 deploymentTarget: @@ -13,8 +13,32 @@ configs: Release: release Debug: debug +packages: + TICoordinatorKit: + url: https://github.com/TouchInstinct/TICoordinatorKit + version: 1.1.6 + LeadKit: + url: https://github.com/TouchInstinct/LeadKit + version: 1.4.0 + SnapKit: + url: https://github.com/SnapKit/SnapKit + version: 5.0.1 + targets: {{project_name}}: + dependencies: + - package: LeadKit + product: TISwiftUtils + - package: LeadKit + product: TIFoundationUtils + - package: LeadKit + product: TIKeychainUtils + - package: LeadKit + product: TIUIKitCore + - package: LeadKit + product: TIUIElements + - package: LeadKit + product: TITableKitUtils settings: base: SWIFT_VERSION: 5.0 @@ -32,10 +56,6 @@ targets: GOOGLE_SERVICE_INFO_PLIST_PATH: $(SRCROOT)/$(TARGET_NAME)/Resources/AppStore-GoogleService-Info.plist type: application platform: iOS - postbuildScripts: - - script: "\"${PODS_ROOT}/FirebaseCrashlytics/run\" --google-service-plist ${GOOGLE_SERVICE_INFO_PLIST_PATH}" - name: Firebase - runOnlyWhenInstalling: true sources: - path: {{project_name}} excludes: @@ -50,7 +70,7 @@ targets: buildPhase: sources - path: {{project_name}}/Extensions buildPhase: sources - - path: {{project_name}}/Generated + - path: Generated buildPhase: sources - path: {{project_name}}/Networking buildPhase: sources @@ -70,13 +90,13 @@ aggregateTargets: buildScripts: - name: Localization script: | - readonly PRODUCT_NAME={{project_name}} + readonly PRODUCT_NAME="{{project_name}}" . build-scripts/xcode/build_phases/localization.sh inputFiles: - $(SRCROOT)/common/strings/default_common_strings_ru.json - name: API Generator - script: . build-scripts/xcode/build_phases/api_generator.sh 1.4.0-alpha3 {{project_name}}/Generated + script: #. build-scripts/xcode/build_phases/api_generator.sh 1.4.0-alpha3 {{project_name}}/Generated - name: License List script: | @@ -90,10 +110,10 @@ aggregateTargets: readonly PODS_ROOT="${SRCROOT}/Pods" . ${SRCROOT}/build_phases/check_pods_manifest.sh inputFiles: - - ${SRCROOT}/Podfile.lock - - ${PODS_ROOT}/Manifest.lock + - ${SRCROOT}/Podfile.lock + - ${PODS_ROOT}/Manifest.lock outputFiles: - - $(DERIVED_FILE_DIR)/Pods-Ubrd-checkManifestLockResult.txt + - $(DERIVED_FILE_DIR)/Pods-Ubrd-checkManifestLockResult.txt - name: Swiftlint script: | @@ -101,16 +121,14 @@ aggregateTargets: readonly SCRIPT_DIR="${SRCROOT}/build-scripts/xcode/build_phases" . ${SCRIPT_DIR}/swiftlint.sh inputFileLists: - - $(SRCROOT)/build_phases/code_lint_folders.xcfilelist - basedOnDependencyAnalysis: false + - $(SRCROOT)/build_phases/code_lint_folders.xcfilelist - name: CopyPaste Detection script: | readonly SCRIPT_DIR="${SRCROOT}/build-scripts/xcode/build_phases" . build-scripts/xcode/build_phases/copy_paste_detection.sh Localization Generated Pods inputFileLists: - - $(SRCROOT)/build_phases/code_lint_folders.xcfilelist - basedOnDependencyAnalysis: false + - $(SRCROOT)/build_phases/code_lint_folders.xcfilelist UnusedDetection: buildScripts: @@ -118,6 +136,11 @@ aggregateTargets: script: . build-scripts/xcode/build_phases/unused.sh schemes: + {{project_name}}: + build: + targets: + {{project_name}}: all + CodeGen: build: targets: