Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
3 changes: 2 additions & 1 deletion loans/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ buildscript {

rootProject.allprojects {
repositories {
mavenLocal()
maven {
url "https://artifactory.smallcase.com/artifactory/gradle-dev-local"
credentials {
Expand Down Expand Up @@ -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'
}
5 changes: 3 additions & 2 deletions scgateway/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version '1.0-SNAPSHOT'

buildscript {
repositories {
mavenLocal()
google()
jcenter()
}
Expand All @@ -15,6 +16,7 @@ buildscript {

rootProject.allprojects {
repositories {
mavenLocal()
maven {
url "https://artifactory.smallcase.com/artifactory/gradle-dev-local"
credentials {
Expand Down Expand Up @@ -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'
}
2 changes: 1 addition & 1 deletion scgateway/lib/scgateway_flutter_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String?> getSdkVersion() async {
String? sdkVersion;
Expand Down
2 changes: 1 addition & 1 deletion scgateway/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
114 changes: 114 additions & 0 deletions scripts/check_elf_alignment.sh
Original file line number Diff line number Diff line change
@@ -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 <pagesize_kb>"; }; 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 "====================="


71 changes: 71 additions & 0 deletions scripts/reset.sh
Original file line number Diff line number Diff line change
@@ -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"


1 change: 1 addition & 0 deletions smart_investing/android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
allprojects {
repositories {
mavenLocal()
google()
mavenCentral()
}
Expand Down
2 changes: 1 addition & 1 deletion smart_investing/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>12.0</string>
<string>13.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion smart_investing/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions smart_investing/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
A65A22CF8499D3153DE3CB8F /* [CP] Embed Pods Frameworks */,
B7D1B14AD0C99264C7FFD2EA /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -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 = (
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down