Skip to content

Commit b82999a

Browse files
chore: update README with development instructions, add mavenLocal() to build.gradle files, and update dependencies in pubspec.lock
1 parent 924d53d commit b82999a

8 files changed

Lines changed: 239 additions & 77 deletions

File tree

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,28 @@ To deploy a new version of the package:
3737

3838
5. **Run the publish workflow**
3939
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.
40+
41+
## Development
42+
43+
### Reset (clean + reinstall deps)
44+
45+
Use the reset script to clean build artifacts (Flutter, Gradle, CocoaPods), lock files and reinstall dependencies across all packages (`scgateway`, `loans`, `smart_investing`):
46+
47+
```bash
48+
bash scripts/reset.sh
49+
```
50+
51+
Then run the example app:
52+
53+
```bash
54+
cd smart_investing && flutter run
55+
```
56+
57+
### Check ELF 16KB alignment in an APK
58+
59+
Build the APK, then run the checker (requires `zipalign`, `objdump` in PATH):
60+
61+
```bash
62+
cd smart_investing && flutter build apk --release
63+
bash scripts/check_elf_alignment.sh smart_investing/build/app/outputs/flutter-apk/app-release.apk
64+
```

loans/android/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ buildscript {
1515

1616
rootProject.allprojects {
1717
repositories {
18+
mavenLocal()
1819
maven {
1920
url "https://artifactory.smallcase.com/artifactory/gradle-dev-local"
2021
credentials {
@@ -64,5 +65,5 @@ android {
6465

6566
dependencies {
6667
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
67-
implementation "com.smallcase.loans:sdk:3.1.1"
68+
implementation 'com.smallcase.loans:sdk-null:3.1.1-66-release'
6869
}

scgateway/android/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version '1.0-SNAPSHOT'
33

44
buildscript {
55
repositories {
6+
mavenLocal()
67
google()
78
jcenter()
89
}
@@ -15,6 +16,7 @@ buildscript {
1516

1617
rootProject.allprojects {
1718
repositories {
19+
mavenLocal()
1820
maven {
1921
url "https://artifactory.smallcase.com/artifactory/gradle-dev-local"
2022
credentials {
@@ -64,6 +66,5 @@ android {
6466

6567
dependencies {
6668
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
67-
68-
implementation "com.smallcase.gateway:sdk:4.4.0"
69+
implementation "com.smallcase.gateway:sdk-null:4.4.0-3180-release"
6970
}

scripts/check_elf_alignment.sh

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#!/bin/bash
2+
progname="${0##*/}"
3+
progname="${progname%.sh}"
4+
5+
# usage: check_elf_alignment.sh [path to *.so files|path to *.apk|path to *.apex]
6+
7+
cleanup_trap() {
8+
if [ -n "${tmp:-}" -a -d "${tmp:-}" ]; then
9+
rm -rf ${tmp}
10+
fi
11+
exit $1
12+
}
13+
14+
usage() {
15+
echo "Host side script to check the ELF alignment of shared libraries."
16+
echo "Shared libraries are reported ALIGNED when their ELF regions are"
17+
echo "16 KB or 64 KB aligned. Otherwise they are reported as UNALIGNED."
18+
echo
19+
echo "Usage: ${progname} [input-path|input-APK|input-APEX]"
20+
}
21+
22+
if [ ${#} -ne 1 ]; then
23+
usage
24+
exit 1
25+
fi
26+
27+
case ${1} in
28+
--help | -h | -\?)
29+
usage
30+
exit 0
31+
;;
32+
33+
*)
34+
dir="${1}"
35+
;;
36+
esac
37+
38+
if ! [ -f "${dir}" -o -d "${dir}" ]; then
39+
echo "Invalid file: ${dir}" >&2
40+
exit 1
41+
fi
42+
43+
if [[ "${dir}" == *.apk ]]; then
44+
trap 'cleanup_trap 0' EXIT
45+
46+
echo
47+
echo "Recursively analyzing $dir"
48+
echo
49+
50+
if { zipalign --help 2>&1 | grep -q "\-P <pagesize_kb>"; }; then
51+
echo "=== APK zip-alignment ==="
52+
zipalign -v -c -P 16 4 "${dir}" | egrep 'lib/arm64-v8a|lib/x86_64|Verification'
53+
echo "========================="
54+
else
55+
echo "NOTICE: Zip alignment check requires build-tools version 35.0.0-rc3 or higher."
56+
echo " You can install the latest build-tools by running the below command"
57+
echo " and updating your $PATH:"
58+
echo
59+
echo " sdkmanager \"build-tools;35.0.0-rc3\""
60+
fi
61+
62+
dir_filename=$(basename "${dir}")
63+
tmp=$(mktemp -d -t "${dir_filename%.apk}_out_XXXXX")
64+
unzip "${dir}" lib/* -d "${tmp}" >/dev/null 2>&1
65+
dir="${tmp}"
66+
fi
67+
68+
if [[ "${dir}" == *.apex ]]; then
69+
trap 'cleanup_trap 0' EXIT
70+
71+
echo
72+
echo "Recursively analyzing $dir"
73+
echo
74+
75+
dir_filename=$(basename "${dir}")
76+
tmp=$(mktemp -d -t "${dir_filename%.apex}_out_XXXXX")
77+
deapexer extract "${dir}" "${tmp}" || { echo "Failed to deapex." && exit 1; }
78+
dir="${tmp}"
79+
fi
80+
81+
RED="\e[31m"
82+
GREEN="\e[32m"
83+
ENDCOLOR="\e[0m"
84+
85+
unaligned_libs=()
86+
87+
echo
88+
echo "=== ELF alignment ==="
89+
90+
matches="$(find "${dir}" -type f)"
91+
IFS=$'\n'
92+
for match in $matches; do
93+
[[ "${match}" == *".apk" ]] && echo "WARNING: doesn't recursively inspect .apk file: ${match}"
94+
[[ "${match}" == *".apex" ]] && echo "WARNING: doesn't recursively inspect .apex file: ${match}"
95+
96+
[[ $(file "${match}") == *"ELF"* ]] || continue
97+
98+
res="$(objdump -p "${match}" | grep LOAD | awk '{ print $NF }' | head -1)"
99+
if [[ $res =~ 2\*\*(1[4-9]|[2-9][0-9]|[1-9][0-9]{2,}) ]]; then
100+
echo -e "${match}: ${GREEN}ALIGNED${ENDCOLOR} ($res)"
101+
else
102+
echo -e "${match}: ${RED}UNALIGNED${ENDCOLOR} ($res)"
103+
unaligned_libs+=("${match}")
104+
fi
105+
done
106+
107+
if [ ${#unaligned_libs[@]} -gt 0 ]; then
108+
echo -e "${RED}Found ${#unaligned_libs[@]} unaligned libs (only arm64-v8a/x86_64 libs need to be aligned).${ENDCOLOR}"
109+
elif [ -n "${dir_filename:-}" ]; then
110+
echo -e "ELF Verification Successful"
111+
fi
112+
echo "====================="
113+
114+

scripts/reset.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Resolve repo root (scripts/..)
6+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
7+
8+
echo "Repo root: ${REPO_ROOT}"
9+
10+
clean_flutter_pkg() {
11+
local pkg_dir="$1"
12+
if [[ ! -d "${pkg_dir}" ]]; then
13+
return 0
14+
fi
15+
16+
echo "\n==> Cleaning ${pkg_dir}"
17+
18+
# Generic Flutter/Dart
19+
rm -rf "${pkg_dir}/build" \
20+
"${pkg_dir}/.dart_tool" \
21+
"${pkg_dir}/pubspec.lock" || true
22+
23+
# Android bits (delete only)
24+
if [[ -d "${pkg_dir}/android" ]]; then
25+
rm -rf "${pkg_dir}/android/build" \
26+
"${pkg_dir}/android/.gradle" \
27+
"${pkg_dir}/android/.cxx" || true
28+
fi
29+
30+
# iOS bits (delete only)
31+
if [[ -d "${pkg_dir}/ios" ]]; then
32+
rm -rf "${pkg_dir}/ios/Pods" \
33+
"${pkg_dir}/ios/Podfile.lock" \
34+
"${pkg_dir}/ios/.symlinks" \
35+
"${pkg_dir}/ios/Flutter/Flutter.podspec" \
36+
"${pkg_dir}/ios/Flutter/ephemeral" || true
37+
fi
38+
39+
# macOS bits (delete only)
40+
if [[ -d "${pkg_dir}/macos" ]]; then
41+
rm -rf "${pkg_dir}/macos/Pods" \
42+
"${pkg_dir}/macos/Podfile.lock" || true
43+
fi
44+
}
45+
46+
flutter_pub_get() {
47+
local pkg_dir="$1"
48+
if [[ -d "${pkg_dir}" ]]; then
49+
echo "\n==> Getting dependencies in ${pkg_dir}"
50+
(cd "${pkg_dir}" && flutter pub get)
51+
fi
52+
}
53+
54+
#!/usr/bin/env bash
55+
56+
# Packages in this monorepo
57+
SCGATEWAY_DIR="${REPO_ROOT}/scgateway"
58+
LOANS_DIR="${REPO_ROOT}/loans"
59+
SMART_INVESTING_DIR="${REPO_ROOT}/smart_investing"
60+
61+
echo "\n=== Cleaning packages ==="
62+
clean_flutter_pkg "${SCGATEWAY_DIR}"
63+
clean_flutter_pkg "${LOANS_DIR}"
64+
clean_flutter_pkg "${SMART_INVESTING_DIR}"
65+
66+
echo "\nDone. Next steps (run manually as needed):"
67+
echo " - cd scgateway && flutter pub get"
68+
echo " - cd loans && flutter pub get"
69+
echo " - cd smart_investing && flutter pub get && flutter run"
70+
71+

smart_investing/android/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
allprojects {
22
repositories {
3+
mavenLocal()
34
google()
45
mavenCentral()
56
}

smart_investing/ios/Podfile.lock

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)