Skip to content

feat(iap): add plugin native source support to Android build templates#9

Open
A-Legg wants to merge 2 commits into
GenericJam:masterfrom
A-Legg:iap-plugin-support
Open

feat(iap): add plugin native source support to Android build templates#9
A-Legg wants to merge 2 commits into
GenericJam:masterfrom
A-Legg:iap-plugin-support

Conversation

@A-Legg
Copy link
Copy Markdown

@A-Legg A-Legg commented May 24, 2026

feat(iap): add plugin native source support to Android build templates

This PR adds the template-level groundwork for mob_dev to auto-discover and compile plugin native C sources into Android builds.

Changes

AndroidManifest.xml.eex

Adds the com.android.vending.BILLING permission required by Google Play Billing (used by mob_iap and any other IAP plugin). Included unconditionally — it has no runtime effect if the app doesn't use IAP, and it avoids generator complexity.

build.zig.eex

Adds a new -Dproject_plugin_sources option that accepts comma-separated name:path pairs. When mob_dev scans dependencies and finds .c files under priv/native/android/jni/, it will pass them via this flag. The build.zig template compiles each entry as a plain C object and links it into lib<app>.so.

Coordination

This is the mob_new counterpart to the mob_dev plugin auto-discovery work and the mob runtime NIF hooks PR:

Backwards compatibility

Projects without plugin native sources pass an empty string (the default), and the new iteration block is skipped. No effect on existing builds.

What's still needed in mob_dev

mob_dev's NativeBuild module needs to:

  1. Scan deps/*/priv/native/android/jni/*.c before each Android zig build
  2. Produce name:path pairs and pass -Dproject_plugin_sources=...
  3. Copy plugin .kt files from priv/native/android/ into the project's Java tree
  4. Scan deps/*/priv/native/ios/*.swift and pass -Dproject_swift_sources=... for iOS

These mob_dev changes are planned as a follow-up PR.

Changes:
- AndroidManifest.xml.eex: add com.android.vending.BILLING permission
  for Play Billing (used by mob_iap and any other IAP plugin)
- build.zig.eex: add -Dproject_plugin_sources option that accepts
  comma-separated name:path pairs, allowing mob_dev to auto-discover
  and compile plugin C sources from deps' priv/native/android/jni/

Refs: GenericJam/mob#27
@A-Legg
Copy link
Copy Markdown
Author

A-Legg commented May 24, 2026

🚀 Test app now available: https://github.com/A-Legg/mob_iap_test

This repo demonstrates the full IAP flow end-to-end on both iOS Simulator and Android Emulator. It validates that:

  • StoreKit 2 / Play Billing 7 callbacks reach the BEAM
  • Mob.Test.assigns/1 shows :products state after fetch_products
  • All 5 IAP NIFs (iap_fetch_products, iap_purchase, iap_restore, iap_current_entitlements, iap_manage_subscriptions) return :ok

See the README for step-by-step test instructions + troubleshooting.

The previous one-line comment didn't capture why the permission is
declared unconditionally vs. gated on a generator flag. Expand it to
document both the rationale (avoid generator complexity) and the
tradeoff (Play Console may warn non-IAP apps about the unused
permission) so users know how to opt out.

Template-only change; no behavior shift.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.

1 participant