From 27058c8a1a8abd9e6d1154dafdfb2b8ba441799f Mon Sep 17 00:00:00 2001 From: Sourav Ganguly <95974201+isouravganguly@users.noreply.github.com> Date: Fri, 31 Oct 2025 13:01:18 +0530 Subject: [PATCH 1/2] feat: add 16KB support in android (#53) * chore: update version to 5.2.0 in pubspec.yaml * chore: update README with development instructions, add mavenLocal() to build.gradle files, and update dependencies in pubspec.lock * chore: update Podfile.lock and project settings to support iOS 13.0 * version-bump: gw-4.4.1, loans-3.1.1 * clean: removed .dart_tool, .gradle files * Delete android/.gradle/nb-cache * refactor: revert smart_investing/pubspec.lock --- README.md | 25 ++++ loans/android/build.gradle | 3 +- scgateway/android/build.gradle | 5 +- scripts/check_elf_alignment.sh | 114 ++++++++++++++++++ scripts/reset.sh | 71 +++++++++++ smart_investing/android/build.gradle.kts | 1 + .../ios/Flutter/AppFrameworkInfo.plist | 2 +- smart_investing/ios/Podfile.lock | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 10 +- 9 files changed, 223 insertions(+), 10 deletions(-) create mode 100755 scripts/check_elf_alignment.sh create mode 100644 scripts/reset.sh diff --git a/README.md b/README.md index 8b314d1..44e3851 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,28 @@ To deploy a new version of the package: 5. **Run the publish workflow** Go to [GitHub Actions](https://github.com/smallcase/gw-mob-sdk-flutter/actions) and manually trigger the "🚀 Publish" workflow on the created tag. The workflow will not work on branches - it must be run on a tag. + +## Development + +### Reset (clean + reinstall deps) + +Use the reset script to clean build artifacts (Flutter, Gradle, CocoaPods), lock files and reinstall dependencies across all packages (`scgateway`, `loans`, `smart_investing`): + +```bash +bash scripts/reset.sh +``` + +Then run the example app: + +```bash +cd smart_investing && flutter run +``` + +### Check ELF 16KB alignment in an APK + +Build the APK, then run the checker (requires `zipalign`, `objdump` in PATH): + +```bash +cd smart_investing && flutter build apk --release +bash scripts/check_elf_alignment.sh smart_investing/build/app/outputs/flutter-apk/app-release.apk +``` diff --git a/loans/android/build.gradle b/loans/android/build.gradle index 3d16abf..3b22fdf 100644 --- a/loans/android/build.gradle +++ b/loans/android/build.gradle @@ -15,6 +15,7 @@ buildscript { rootProject.allprojects { repositories { + mavenLocal() maven { url "https://artifactory.smallcase.com/artifactory/gradle-dev-local" credentials { @@ -64,5 +65,5 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation "com.smallcase.loans:sdk:3.1.1" + implementation 'com.smallcase.loans:sdk:3.1.1' } diff --git a/scgateway/android/build.gradle b/scgateway/android/build.gradle index 88f4898..0d7061e 100644 --- a/scgateway/android/build.gradle +++ b/scgateway/android/build.gradle @@ -3,6 +3,7 @@ version '1.0-SNAPSHOT' buildscript { repositories { + mavenLocal() google() jcenter() } @@ -15,6 +16,7 @@ buildscript { rootProject.allprojects { repositories { + mavenLocal() maven { url "https://artifactory.smallcase.com/artifactory/gradle-dev-local" credentials { @@ -64,6 +66,5 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - - implementation "com.smallcase.gateway:sdk:4.4.0" + implementation 'com.smallcase.gateway:sdk:4.4.1' } diff --git a/scripts/check_elf_alignment.sh b/scripts/check_elf_alignment.sh new file mode 100755 index 0000000..85e9e0f --- /dev/null +++ b/scripts/check_elf_alignment.sh @@ -0,0 +1,114 @@ +#!/bin/bash +progname="${0##*/}" +progname="${progname%.sh}" + +# usage: check_elf_alignment.sh [path to *.so files|path to *.apk|path to *.apex] + +cleanup_trap() { + if [ -n "${tmp:-}" -a -d "${tmp:-}" ]; then + rm -rf ${tmp} + fi + exit $1 +} + +usage() { + echo "Host side script to check the ELF alignment of shared libraries." + echo "Shared libraries are reported ALIGNED when their ELF regions are" + echo "16 KB or 64 KB aligned. Otherwise they are reported as UNALIGNED." + echo + echo "Usage: ${progname} [input-path|input-APK|input-APEX]" +} + +if [ ${#} -ne 1 ]; then + usage + exit 1 +fi + +case ${1} in + --help | -h | -\?) + usage + exit 0 + ;; + + *) + dir="${1}" + ;; +esac + +if ! [ -f "${dir}" -o -d "${dir}" ]; then + echo "Invalid file: ${dir}" >&2 + exit 1 +fi + +if [[ "${dir}" == *.apk ]]; then + trap 'cleanup_trap 0' EXIT + + echo + echo "Recursively analyzing $dir" + echo + + if { zipalign --help 2>&1 | grep -q "\-P "; }; then + echo "=== APK zip-alignment ===" + zipalign -v -c -P 16 4 "${dir}" | egrep 'lib/arm64-v8a|lib/x86_64|Verification' + echo "=========================" + else + echo "NOTICE: Zip alignment check requires build-tools version 35.0.0-rc3 or higher." + echo " You can install the latest build-tools by running the below command" + echo " and updating your $PATH:" + echo + echo " sdkmanager \"build-tools;35.0.0-rc3\"" + fi + + dir_filename=$(basename "${dir}") + tmp=$(mktemp -d -t "${dir_filename%.apk}_out_XXXXX") + unzip "${dir}" lib/* -d "${tmp}" >/dev/null 2>&1 + dir="${tmp}" +fi + +if [[ "${dir}" == *.apex ]]; then + trap 'cleanup_trap 0' EXIT + + echo + echo "Recursively analyzing $dir" + echo + + dir_filename=$(basename "${dir}") + tmp=$(mktemp -d -t "${dir_filename%.apex}_out_XXXXX") + deapexer extract "${dir}" "${tmp}" || { echo "Failed to deapex." && exit 1; } + dir="${tmp}" +fi + +RED="\e[31m" +GREEN="\e[32m" +ENDCOLOR="\e[0m" + +unaligned_libs=() + +echo +echo "=== ELF alignment ===" + +matches="$(find "${dir}" -type f)" +IFS=$'\n' +for match in $matches; do + [[ "${match}" == *".apk" ]] && echo "WARNING: doesn't recursively inspect .apk file: ${match}" + [[ "${match}" == *".apex" ]] && echo "WARNING: doesn't recursively inspect .apex file: ${match}" + + [[ $(file "${match}") == *"ELF"* ]] || continue + + res="$(objdump -p "${match}" | grep LOAD | awk '{ print $NF }' | head -1)" + if [[ $res =~ 2\*\*(1[4-9]|[2-9][0-9]|[1-9][0-9]{2,}) ]]; then + echo -e "${match}: ${GREEN}ALIGNED${ENDCOLOR} ($res)" + else + echo -e "${match}: ${RED}UNALIGNED${ENDCOLOR} ($res)" + unaligned_libs+=("${match}") + fi +done + +if [ ${#unaligned_libs[@]} -gt 0 ]; then + echo -e "${RED}Found ${#unaligned_libs[@]} unaligned libs (only arm64-v8a/x86_64 libs need to be aligned).${ENDCOLOR}" +elif [ -n "${dir_filename:-}" ]; then + echo -e "ELF Verification Successful" +fi +echo "=====================" + + diff --git a/scripts/reset.sh b/scripts/reset.sh new file mode 100644 index 0000000..496a8ea --- /dev/null +++ b/scripts/reset.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Resolve repo root (scripts/..) +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +echo "Repo root: ${REPO_ROOT}" + +clean_flutter_pkg() { + local pkg_dir="$1" + if [[ ! -d "${pkg_dir}" ]]; then + return 0 + fi + + echo "\n==> Cleaning ${pkg_dir}" + + # Generic Flutter/Dart + rm -rf "${pkg_dir}/build" \ + "${pkg_dir}/.dart_tool" \ + "${pkg_dir}/pubspec.lock" || true + + # Android bits (delete only) + if [[ -d "${pkg_dir}/android" ]]; then + rm -rf "${pkg_dir}/android/build" \ + "${pkg_dir}/android/.gradle" \ + "${pkg_dir}/android/.cxx" || true + fi + + # iOS bits (delete only) + if [[ -d "${pkg_dir}/ios" ]]; then + rm -rf "${pkg_dir}/ios/Pods" \ + "${pkg_dir}/ios/Podfile.lock" \ + "${pkg_dir}/ios/.symlinks" \ + "${pkg_dir}/ios/Flutter/Flutter.podspec" \ + "${pkg_dir}/ios/Flutter/ephemeral" || true + fi + + # macOS bits (delete only) + if [[ -d "${pkg_dir}/macos" ]]; then + rm -rf "${pkg_dir}/macos/Pods" \ + "${pkg_dir}/macos/Podfile.lock" || true + fi +} + +flutter_pub_get() { + local pkg_dir="$1" + if [[ -d "${pkg_dir}" ]]; then + echo "\n==> Getting dependencies in ${pkg_dir}" + (cd "${pkg_dir}" && flutter pub get) + fi +} + +#!/usr/bin/env bash + +# Packages in this monorepo +SCGATEWAY_DIR="${REPO_ROOT}/scgateway" +LOANS_DIR="${REPO_ROOT}/loans" +SMART_INVESTING_DIR="${REPO_ROOT}/smart_investing" + +echo "\n=== Cleaning packages ===" +clean_flutter_pkg "${SCGATEWAY_DIR}" +clean_flutter_pkg "${LOANS_DIR}" +clean_flutter_pkg "${SMART_INVESTING_DIR}" + +echo "\nDone. Next steps (run manually as needed):" +echo " - cd scgateway && flutter pub get" +echo " - cd loans && flutter pub get" +echo " - cd smart_investing && flutter pub get && flutter run" + + diff --git a/smart_investing/android/build.gradle.kts b/smart_investing/android/build.gradle.kts index 89176ef..20b1774 100644 --- a/smart_investing/android/build.gradle.kts +++ b/smart_investing/android/build.gradle.kts @@ -1,5 +1,6 @@ allprojects { repositories { + mavenLocal() google() mavenCentral() } diff --git a/smart_investing/ios/Flutter/AppFrameworkInfo.plist b/smart_investing/ios/Flutter/AppFrameworkInfo.plist index 7c56964..1dc6cf7 100644 --- a/smart_investing/ios/Flutter/AppFrameworkInfo.plist +++ b/smart_investing/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 12.0 + 13.0 diff --git a/smart_investing/ios/Podfile.lock b/smart_investing/ios/Podfile.lock index 5688906..3290a48 100644 --- a/smart_investing/ios/Podfile.lock +++ b/smart_investing/ios/Podfile.lock @@ -38,7 +38,7 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/scloans/ios" SPEC CHECKSUMS: - Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 + Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 Mixpanel-swift: 7b26468fc0e2e521104e51d65c4bbf7cab8162f8 mixpanel_flutter: a0b6b937035899cd01951735ad5f87718b2ffee5 SCGateway: f502f44122537b777861093ef97f67ccc311d4d0 diff --git a/smart_investing/ios/Runner.xcodeproj/project.pbxproj b/smart_investing/ios/Runner.xcodeproj/project.pbxproj index b9bc85c..6eab9ec 100644 --- a/smart_investing/ios/Runner.xcodeproj/project.pbxproj +++ b/smart_investing/ios/Runner.xcodeproj/project.pbxproj @@ -197,7 +197,7 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - A65A22CF8499D3153DE3CB8F /* [CP] Embed Pods Frameworks */, + B7D1B14AD0C99264C7FFD2EA /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -322,7 +322,7 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - A65A22CF8499D3153DE3CB8F /* [CP] Embed Pods Frameworks */ = { + B7D1B14AD0C99264C7FFD2EA /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -454,7 +454,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -586,7 +586,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -637,7 +637,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; From a92247aec62749e3de6cd631dad955c4dffa1ba7 Mon Sep 17 00:00:00 2001 From: Sourav Ganguly <95974201+isouravganguly@users.noreply.github.com> Date: Fri, 31 Oct 2025 18:36:20 +0530 Subject: [PATCH 2/2] chore(prod): scg:5.2.1 (#54) --- scgateway/lib/scgateway_flutter_plugin.dart | 2 +- scgateway/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scgateway/lib/scgateway_flutter_plugin.dart b/scgateway/lib/scgateway_flutter_plugin.dart index b9e776c..469932f 100644 --- a/scgateway/lib/scgateway_flutter_plugin.dart +++ b/scgateway/lib/scgateway_flutter_plugin.dart @@ -50,7 +50,7 @@ class ScgatewayFlutterPlugin { static const MethodChannel _channel = const MethodChannel('scgateway_flutter_plugin'); - static const String _flutterPluginVersion = "4.0.0"; + static const String _flutterPluginVersion = "5.2.1"; static Future getSdkVersion() async { String? sdkVersion; diff --git a/scgateway/pubspec.yaml b/scgateway/pubspec.yaml index a7aa784..6369dac 100644 --- a/scgateway/pubspec.yaml +++ b/scgateway/pubspec.yaml @@ -1,6 +1,6 @@ name: scgateway_flutter_plugin description: Scgateway Flutter plugin. -version: 5.2.0 +version: 5.2.1 homepage: https://github.com/smallcase/gw-mob-sdk-flutter # The following line prevents the package from being accidentally published to