Skip to content

feat: add native SDK debug mode switch - #209

Closed
DeepakSingh80 wants to merge 14 commits into
developmentfrom
feature/native-sdk-debug-mode
Closed

DeepakSingh80 wants to merge 14 commits into
developmentfrom
feature/native-sdk-debug-mode

Conversation

@DeepakSingh80

@DeepakSingh80 DeepakSingh80 commented Sep 28, 2026 •

Copy link
Copy Markdown

Summary

Lets host apps switch the RN wrapper to debug builds of the native Gateway/Loans SDKs (WebView inspection, debug logging) without a separate branch or npm release.

Background

This package is a bridge between a React Native app's JavaScript and the native Gateway and Loans SDKs, which exist separately for Android and iOS. The package doesn't bundle those SDKs. It declares them as dependencies, which Gradle (Android) and CocoaPods (iOS) download when the host app builds.

Host app JS  →  react-native-smallcase-gateway (bridge)  →  native Gateway / Loans SDK

Until now the dependency list was hardcoded to the release SDKs. Debugging an issue inside a native SDK meant hand-editing the pins on a separate branch (the "INTERNAL TEST PIN" commits).

Release SDK build Debug SDK build
Audience Production users smallcase developers / QA
Logging Minimal Detailed debug logs
WebView inspection Off On (Chrome / Safari dev tools)
Published to Public registries smallcase internal registries only

Changes

  • Native SDK pins move to native-sdk.json, with release (default, unchanged: Android 6.1.4 / 5.4.0, iOS SCGateway 7.2.2 / SCLoans 7.5.0) and debug entries.
  • Android: android/build.gradle reads the pins. Opt in with SmallcaseGateway_sdkMode=debug in the host's gradle.properties.
  • iOS: the podspec reads the pins. Opt in with SMALLCASE_SDK_MODE=debug pod install, with cocoapodspec-internal added as a Podfile source.
  • An unknown mode, or debug mode with a missing pin, fails the build with an explicit error.
  • native-sdk.json is added to files so it ships in the npm package.
  • README section documenting debug mode.

Note: the branch was cut from prod (v7.7.2), so this PR also carries prod commits that development hasn't synced yet.

How release and debug work separately

There is one npm package and one codebase. Release and debug differ only in which native SDK versions get downloaded, and the host app picks one at build / install time:

                       native-sdk.json
                   ┌───────────┴───────────┐
                "release"               "debug"
            (public SDK pins)     (internal debug SDK pins)
                   │                       │
   no flag set (default) ──┘               └── flag set by host app
                                               Android: SmallcaseGateway_sdkMode=debug
                                               iOS:     SMALLCASE_SDK_MODE=debug pod install
  1. When the host app builds, Gradle evaluates android/build.gradle and CocoaPods evaluates the podspec on pod install.
  2. Each one reads native-sdk.json and looks for the mode flag. If the flag is missing, the mode is release.
  3. It takes the pins for that mode and platform and declares them as dependencies:
    • Release: the public SDKs from the public Artifactory repo / CocoaPods trunk. External customers are on this path and need no change.
    • Debug: the debug SDKs from SCGateway-internal (Android) or cocoapodspec-internal (iOS). This path is only taken when someone opts in, so the published package never makes customers resolve internal artifacts.
  4. If the mode is unknown, or a debug pin is null, the build stops with an explicit error instead of silently falling back.

The mode is set per project / per pod install, not per Debug/Release build variant of the host app. That keeps Android and iOS behaving the same.

How to use debug mode

Requires internal access: Artifactory SCGateway-internal for Android, and SSH access to smallcase/cocoapodspec-internal for iOS.

Android

  1. In the host app's android/gradle.properties, add:
    SmallcaseGateway_sdkMode=debug
  2. Sync / rebuild (for example npx react-native run-android). Gradle now resolves the debug SDKs.
  3. To switch back, remove the line and rebuild.

iOS

  1. At the top of the host app's ios/Podfile, add:
    source 'git@github.com:smallcase/cocoapodspec-internal.git'
    source 'https://cdn.cocoapods.org/'
  2. From the ios folder, run:
    SMALLCASE_SDK_MODE=debug pod install
  3. Build the app. It now links the debug SDKs.
  4. To switch back, run a plain pod install.

Things to know before relying on it

  • Not usable end to end yet. Every debug pin in native-sdk.json is still null, so turning on debug mode fails with the "no SDK pinned" error until real debug versions are filled in.
  • iOS is blocked on the native side. gw-mob-ios BuildScripts/phases/create-xc-framework.sh archives without -configuration, so it always builds Release. A real debug xcframework needs -configuration Debug there plus a CI run.
  • Don't ship debug SDKs to production. The mode is per project, not per build type. If sdkMode=debug is left in gradle.properties, release APKs also get the debug SDK. On iOS, the mode from the last pod install stays in effect. Switch back before building for the Play Store / App Store.
  • Internal access is required for debug mode (see above). External customers stay on release and are unaffected.

Follow-ups

  • Fill in the debug pins with published internal debug versions.
  • iOS: add -configuration Debug to the xcframework build in gw-mob-ios and publish a debug pod.
  • Consider using debugImplementation <debug pin> / releaseImplementation <release pin> on Android in debug mode, so a release build can never pick up the debug SDK.
  • Consider documenting ENV['SMALLCASE_SDK_MODE'] = 'debug' at the top of the Podfile, so teammates and CI don't depend on remembering the env var.
  • Rebase onto / retarget development.

Test plan

  • pod ipc spec: release mode resolves to the same SDK versions as before; debug mode with sample pins resolves to them; unpinned or unknown modes error out.
  • Gradle sync in a host app, in release mode and in debug mode (not run locally).

🤖 Generated with Claude Code

dporwal-shipit and others added 13 commits June 11, 2026 12:17
* bump Loans SDK to dark-theme internal release (Android 5.1.4-91, iOS … (#195)

* bump Loans SDK to dark-theme internal release (Android 5.1.4-91, iOS 7.1.2-44)

* chore(loans): bump loans SDK pin to sdk-sourav-native-dark-theme-cb54bf9 (5.1.4-92-release)

* fix(proguard): drop stale loans repackage workaround, keep R8 full mode on

* chore: update Loans native SDK dependencies

* chore(release): 7.5.0

* chore: use default R8 mode in sample app

* chore(android): bump Loans SDK to 5.3.0

* fix(android): keep SCGateway classes for R8

* docs(changelog): document v7.5.0 changes

* chore(release): 7.6.0
# Conflicts:
#	android/build.gradle
#	react-native-smallcase-gateway.podspec
#	smart_investing_react_native/android/app/proguard-rules.pro
#	smart_investing_react_native/android/gradle.properties
#	smart_investing_react_native/ios/Podfile.lock
#	smart_investing_react_native/yarn.lock
chore(android): bump Loans SDK to 5.3.1
* chore(android): bump Loans SDK to 5.3.2

* chore(release): 7.6.2
* feat: add Loans KYC permission usage descriptions

* chore: bump SCLoans iOS SDK to 7.4.0

* chore(release): 7.7.0
* feat: expose webview-as-a-service

* chore: update native SDK release dependencies

* chore(release): 7.7.1
* chore(loans): update native SDK release dependencies

* chore(release): 7.7.2

* chore(native): update gateway SDKs

* chore(loans): use production native SDKs

* docs(release): clarify production dependencies

* docs(release): list native SDK versions
Move the native Gateway and Loans SDK pins into native-sdk.json with
release and debug entries. Host apps opt into debug builds of the
native SDKs with SmallcaseGateway_sdkMode=debug (Android) or
SMALLCASE_SDK_MODE=debug pod install (iOS); release stays the default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DeepakSingh80
DeepakSingh80 changed the base branch from development to prod September 28, 2026 18:33
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DeepakSingh80
DeepakSingh80 changed the base branch from prod to development September 30, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants