Cross platform strategy

From FerroxLabs/murage · View interactive version

Cross platform strategy is an AI agent skill from the GitHub repository FerroxLabs/murage. Guides expert-level cross-platform mobile strategy implementation: architecture and best-practices decision frameworks, production-ready patterns, and concrete templates for cross platform strategy workflows. Use when the user asks about cross-platform mobile strategy, cross platform strategy config

How to use this skill

Skill file

Cross-Platform Mobile Strategy

When to Use

Use this skill when:

Do NOT use this skill when:


Process

Step 1: Extract and Classify Project Requirements

Before recommending any framework, gather structured information about the project. If the user has not provided it, ask directly.


Step 2: Apply the Framework Selection Decision Tree

Use the following ordered decision logic. Work top-to-bottom and stop at the first match.


Step 3: Design the Shared Architecture Layers

Once the framework is chosen, define which code is shared and which is platform-specific using a layered architecture model.


Step 4: Structure the Repository and Project Layout

Define the directory structure before writing a single line of application code. Inconsistent structure is the root cause of most cross-platform maintainability failures.


Step 5: Establish Platform-Specific Handling Patterns

Cross-platform does not mean identical behavior on every platform. Define explicit strategies for where platforms must diverge.


Step 6: Define the Performance Testing and Validation Protocol

Performance on cross-platform is non-trivial. Establish a testing protocol before shipping to production.


Step 7: Establish CI/CD and Quality Gates


Step 8: Document the Architecture Decision Record (ADR)

Every cross-platform strategy engagement should produce at minimum one ADR. This prevents the "why did we choose this?" question 18 months later.


Output Format

Produce a structured Cross-Platform Strategy Report using the following template:

# Cross-Platform Mobile Strategy Report

## Project Context Summary
- **App name / codename:** [name]
- **Target platforms:** [iOS / Android / Both]
- **Feature tier breakdown:** Tier 1: X% | Tier 2: Y% | Tier 3: Z%
- **Team composition:** [N] engineers -- [breakdown of iOS/Android/JS/Dart/Kotlin experience]
- **Performance requirements:** Cold start < Xs | Frame rate target: Xfps | Offline: [None/Cache/Full]
- **Target release timeline:** [date or duration]
- **Existing codebase:** [None / Native iOS / Native Android / Both / Web]

---

## Framework Recommendation

**Recommended framework:** [React Native / Flutter / Kotlin Multiplatform Mobile / Ionic+Capacitor / Native]
**Confidence level:** [High / Medium -- revisit if {condition}]

### Decision Matrix

| Criterion                        | React Native | Flutter | KMM  | Native |
|----------------------------------|:------------:|:-------:|:----:|:------:|
| Team familiarity                 | [H/M/L]      | [H/M/L] | [H/M/L] | [H/M/L] |
| UI consistency requirement       | [H/M/L]      | [H/M/L] | [H/M/L] | [H/M/L] |
| Tier 3 feature volume            | [H/M/L]      | [H/M/L] | [H/M/L] | [H/M/L] |
| Existing codebase integration    | [H/M/L]      | [H/M/L] | [H/M/L] | [H/M/L] |
| Startup performance              | [H/M/L]      | [H/M/L] | [H/M/L] | [H/M/L] |
| Ecosystem maturity               | [H/M/L]      | [H/M/L] | [H/M/L] | [H/M/L] |
| **Total fit score (H=3,M=2,L=1)**| [X/18]       | [X/18]  | [X/18]  | [X/18] |

H = High fit | M = Medium fit | L = Low fit

### Rationale
[2--4 sentences explaining the primary factors that drove the recommendation, 
referencing specific scores from the matrix and project constraints.]

---

## Architecture Blueprint

### Layer Map

| Layer              | Sharing %  | Technology Choice        | Rationale                        |
|--------------------|:----------:|--------------------------|----------------------------------|
| Domain/Business    | 90--100%   | [TypeScript/Dart/Kotlin] | [reason]                         |
| Data / Repository  | 70--90%    | [Ktor/Dio/Axios/SQLite]  | [reason]                         |
| State Management   | 60--80%    | [Zustand/Riverpod/BLoC]  | [reason]                         |
| Navigation         | 50--70%    | [React Nav/GoRouter]     | [reason]                         |
| UI Components      | 30--60%    | [shared + platform split]| [reason]                         |
| Native Bridges     | 0%         | [Swift/Kotlin modules]   | [platform-specific interfaces]   |

### Directory Structure

[project-name]/

├── src/ (or lib/)

│ ├── core/

│ │ ├── api/ # HTTP client, interceptors, base models

│ │ ├── storage/ # Local DB, secure storage wrappers

│ │ ├── navigation/ # Route definitions, navigator configuration

│ │ └── theme/ # Design tokens, colors, typography

│ ├── features/

│ │ ├── [feature-1]/

│ │ │ ├── data/ # Repository impl, DTOs, data sources

│ │ │ ├── domain/ # Use cases, entities, repository interfaces

│ │ │ └── ui/ # Screens, components, view models/hooks

│ │ └── [feature-2]/

│ └── shared/

│ ├── components/ # Reusable UI components

│ └── utils/ # Pure utility functions

├── android/ # Platform-specific Android code

├── ios/ # Platform-specific iOS code

└── docs/

└── adr/ # Architecture Decision Records


---

## Platform-Specific Handling Plan

| Concern                  | iOS Approach                       | Android Approach                   |
|--------------------------|------------------------------------|------------------------------------|
| Navigation gestures      | [specific handling]                | [specific handling]                |
| Safe area insets         | [specific handling]                | [specific handling]                |
| Permission flow          | [Info.plist strings + UX strategy] | [Manifest + runtime request UX]    |
| Push notifications       | [APNs setup]                       | [FCM setup]                        |
| Background tasks         | [BGTaskScheduler/mode]             | [WorkManager]                      |

---

## Performance Targets and Testing Protocol

| Metric                | Target          | Measurement Method              | Test Device                  |
|-----------------------|-----------------|---------------------------------|------------------------------|
| Cold start TTI        | < 2.5 seconds   | [Perfetto / Instruments]        | Snapdragon 665, 4 GB RAM     |
| Scroll frame rate     | 60 fps sustained| [Android Profiler / Instruments]| Same mid-range Android       |
| Memory (steady state) | < 180 MB RSS    | [Memory Profiler]               | All reference devices        |
| JS/UI thread blocking | < 16 ms/frame   | [Flipper / DevTools]            | Both platforms               |

---

## CI/CD Pipeline Requirements

- **Build targets:** iOS (macOS runner) + Android (Linux runner) on every PR
- **Lint gate:** [ESLint+TSC / Dart analyzer / ktlint] -- fail on any error
- **Test gate:** Unit tests > 80% domain/data layer coverage -- fail below threshold
- **E2E smoke test:** [Detox / Maestro / integration_test] on [device farm] for critical paths
- **OTA update eligibility:** JS/Dart bundle-only changes -- document native-change conditions
- **Release automation:** fastlane for signing, building, and submitting to stores

---

## Architecture Decision Record (ADR-001)

**Title:** Cross-Platform Framework Selection  
**Status:** Accepted  
**Date:** [YYYY-MM-DD]

**Context:**  
[Describe the business problem, team constraints, and feature requirements that necessitate this decision.]

**Decision:**  
[State the chosen framework and the specific conditions that determined the choice.]

**Consequences:**  
- Accepted trade-offs: [list 2--3]
- Advantages gained: [list 2--3]

**Alternatives Considered:**  
| Alternative | Rejected Because |
|-------------|-----------------|
| [Framework] | [Specific reason with data] |
| [Framework] | [Specific reason with data] |

**Revisit Condition:**  
[Specific measurable condition under which this decision should be reconsidered, e.g., "If Tier 3 features exceed 25% of the backlog or if team Dart/Flutter expertise exceeds JS expertise."]

Rules

  1. Never recommend a framework before completing the Tier 3 feature audit. If more than 30% of planned features require hardware APIs with no viable plugin, cross-platform adds cost rather than saving it. The Tier 3 threshold is the single most important variable in the decision.
  1. Never equate cross-platform with write-once-run-anywhere. Budget at minimum 20--30% of development effort for platform-specific code, UX polish, and native module work even with the best cross-platform framework. Clients and stakeholders who hear "one codebase" must be corrected early.
  1. Never skip real device testing on mid-range Android. Simulators and even flagship Android devices will pass performance tests that mid-range devices fail. The Snapdragon 665 class device is the gatekeeping benchmark. An app that scrolls at 60 fps on a Pixel 8 but drops to 45 fps on a Galaxy A32 is a failed cross-platform implementation.
  1. Never mix navigation paradigms within a single app. Choosing React Navigation's stack then adding a custom modal navigation system for one feature creates untestable back-stack behavior. Pick one navigation library and use its modal, tab, stack, and drawer primitives exclusively.
  1. Never allow native bridge code to return raw platform types to the JS/Dart layer. Native modules must serialize return values to JSON-compatible or Dart-compatible types at the bridge boundary. Letting NSDate or Java Date objects leak into shared code creates platform-specific handling throughout the application.
  1. Always treat font rendering as a cross-platform concern requiring explicit design approval. The same font size in sp/pt units renders differently due to font metrics differences between San Francisco and Roboto. Get sign-off from design on both platforms, not just on one.
  1. Always enforce a maximum of one state management library per project. Projects that mix Context API, Redux, MobX, and Zustand in the same codebase are unmaintainable within 12 months. Choose one, document why, enforce it in code review.
  1. Never implement offline-first sync as an afterthought. If offline functionality is a requirement, the data layer must be designed offline-first from the first sprint. Retrofitting offline sync onto an online-first architecture requires rewriting the entire data layer and typically costs 3--6 weeks of effort when done late.
  1. Always define OTA update boundaries in writing before shipping the first release. React Native and Expo OTA updates are powerful but violate App Store guidelines if used to change core functionality or bypass review. Document which types of changes are OTA-eligible (copy changes, bug fixes, style adjustments) versus which require a full store submission (new native modules, new permissions, major feature additions).
  1. Never underestimate the cost of framework version upgrades. React Native has historically had breaking changes between major versions; Flutter SDK upgrades occasionally require Dart version migrations; KMM Kotlin version upgrades affect Kotlin/Native ABI compatibility. Budget one sprint per quarter for dependency maintenance. Teams that ignore this for 6+ months often face painful all-at-once upgrade work that disrupts feature delivery.

Edge Cases

Existing Native App Needing Cross-Platform Expansion

When an app exists as a mature native iOS app and the business wants to add Android (or vice versa) using a cross-platform framework, do not attempt to rewrite the iOS app. Instead, implement KMM to extract shared business logic (networking, persistence, domain rules) into a Kotlin shared module that the existing iOS app consumes via a Swift wrapper and the new Android app uses directly. The existing iOS UI stays in UIKit/SwiftUI. New Android UI is built in Jetpack Compose. Code sharing targets the data and domain layers (70--80%) where the highest ROI is, not the UI. This approach preserves years of iOS stability while accelerating Android delivery. Typical timeline to first Android release using this strategy is 4--6 months versus 8--12 months for a full React Native rewrite.

High-Frequency Animation and Game-Like UI

Apps with continuous animations (60--120 fps particle effects, physics simulations, gesture-driven UI with real-time interpolation) are poor cross-platform candidates unless Flutter is chosen specifically for this use case. Flutter's Impeller rendering engine (replacing Skia as of Flutter 3.10+ on iOS and Flutter 3.16+ on Android) provides consistent 60 fps for complex animations. React Native's Animated API with useNativeDriver offloads to the native thread but still has limitations for GPU-intensive scenes. If the app is > 40% animation-driven, evaluate Flutter first. If real-time 3D rendering or game engine integration (Unity, Unreal) is required, cross-platform frameworks are inappropriate -- use Unity's native mobile targets or build a thin native shell around the game engine.

Enterprise MDM and Security Requirements

Enterprise apps distributed via Mobile Device Management (MDM -- Jamf, Intune, VMware Workspace ONE) have additional constraints: app wrapping compatibility, certificate pinning, jailbreak/root detection, and sometimes VPN-only network access. React Native and Flutter apps are compatible with most MDM platforms but require careful handling of certificate pinning (use a network security config on Android and NSAppTransportSecurity on iOS, not a JS-layer implementation). Jailbreak detection must be implemented in native code (Swift/Kotlin), not in JS, because jailbroken devices can hook JS runtime calls. Rooted device detection native libraries (RootBeer for Android, IOSSecuritySuite for iOS) must be bridged in. Document all security controls as native-layer requirements in the Tier 2/Tier 3 feature audit.

Team Split Across Time Zones with Diverging Platform Ownership

When iOS work and Android work are split between teams in different time zones (common in offshore/nearshore arrangements), cross-platform frameworks can paradoxically increase coordination overhead if both teams modify platform-specific bridge code concurrently. Establish clear ownership: shared code (domain, data, state) is owned by the full team with mandatory cross-review; platform-specific bridge code and UI tweaks are owned per-platform team with the opposing team as optional reviewer. Use feature flags to decouple deployment of shared logic from platform-specific UI, allowing each platform team to ship independently when the shared logic is ready. Avoid "big bang" merges of platform-diverged branches -- integrate shared code to main at least weekly.

Low-End Android Device Support (2--3 GB RAM, API Level 23--26)

If the app must target markets where low-end Android devices dominate (South/Southeast Asia, Latin America, Sub-Saharan Africa), apply specific constraints. React Native with Hermes engine is mandatory (not JavaScriptCore) -- Hermes reduces memory by 30--40% and startup time by 10--15% on low-end devices. Flutter AOT compilation already helps, but avoid using many simultaneous opacity animations or image decode operations. Set explicit image cache size limits (React Native Fast Image: FastImage.preload with a maximum cache of 50 MB; Flutter cached_network_image: maxNrOfCacheObjects: 200). Implement aggressive lazy loading -- load screens on first navigation, not at app startup. Target a minimum SDK of API 23 (Android 6.0) which covers > 97% of active Android devices as of 2024.

Multi-Tenant White-Label Apps

Apps that must be reskinned for multiple clients (insurance, fintech, retail platform) require a theming and configuration layer that most cross-platform boilerplates do not provide. Implement a design token system at the core/theme/ layer with all colors, typography, spacing, and icon sets driven by a JSON configuration file loaded at runtime or at build time via environment variables. Use build flavors (Android) and schemes (iOS) to create per-client builds from a single codebase. Never hardcode color values, copy strings, or feature flags in component files. All client-specific values live in the configuration layer. Feature flags at the client level (client A has feature X, client B does not) must be implemented in the domain layer, not in the UI -- the UI reads a capability flag, it does not contain client-specific conditional logic.

Handling a Failed Cross-Platform Migration Midway

When a team has partially migrated from native to cross-platform (or chosen the wrong framework and needs to switch), the worst outcome is abandoning the migration and reverting. Instead, apply a freeze-and-stabilize strategy: stop feature development in the old codebase, complete the migration of the 20% of code that represents 80% of the app's usage (the core user journey screens), and ship that. Leave the remaining 80% of rarely-used screens in the old native code wrapped behind a WebView or deep link handoff, if needed, until the next quarter. Never attempt a big-bang migration -- it creates a multi-month feature freeze that will be cancelled before completion by business pressure.


Example

Input:

"We're a 7-person team (4 senior frontend engineers with strong React/TypeScript, 2 junior iOS developers, 1 Android developer) building a B2C e-commerce app from scratch targeting both iOS and Android. The app needs: product catalog browsing, search, cart and checkout, order tracking with real-time status updates via WebSocket, push notifications, and biometric login (Face ID / fingerprint). We want to ship the iOS version in 4 months and Android 2 months later. What cross-platform strategy do you recommend?"

Output:

Cross-Platform Mobile Strategy Report

Project Context Summary


Framework Recommendation

Recommended framework: React Native (Expo managed workflow, upgrade to bare workflow at month 3)

Confidence level: High

Decision Matrix

| Criterion | React Native | Flutter | KMM | Native |

|----------------------------------|:------------:|:-------:|:----:|:------:|

| Team familiarity | H (4 seniors)| L | L | L |

| UI consistency requirement | M | H | M | H |

| Tier 3 feature volume | H (5%) | H (5%) | H | H |

| Existing codebase integration | H (none) | H | M | H |

| Startup performance | M (Hermes) | H | H | H |

| Ecosystem maturity | H | H | M | H |

| Total fit score (H=3,M=2,L=1)| 16/18 | 13/18 | 12/18| 13/18 |

H = High fit | M = Medium fit | L = Low fit

Rationale

The team's dominant React/TypeScript skillset makes React Native the decisive choice. The 4 senior React engineers will reach full productivity within 2--3 weeks, which is essential for a 4-month iOS deadline. Tier 3 features are minimal (5%) -- biometric login is handled via expo-local-authentication with native backing, and push notifications via expo-notifications (APNs + FCM unified API). Flutter's superior rendering consistency is not a decisive factor here because the app uses standard e-commerce UI patterns rather than custom-designed interactive components. The 2 iOS junior developers will contribute to the native modules layer (Info.plist configuration, APNs certificates, Xcode build settings) and iOS-specific QA, roles well-suited to their experience level.


Architecture Blueprint

Layer Map

| Layer | Sharing % | Technology Choice | Rationale |

|--------------------|:----------:|--------------------------------------------|--------------------------------------------------|

| Domain/Business | 95% | TypeScript, Zod for validation | Pure business rules, no platform dependencies |

| Data / Repository | 85% | Axios + React Query, MMKV, WatermelonDB | React Query handles caching; MMKV for fast KV storage |

| State Management | 80% | Zustand (cart, auth, UI state) | Lightweight, no boilerplate; fits team's React mental model |

| Navigation | 70% | React Navigation 6 (Stack + Bottom Tabs) | Industry standard; robust deep-link support |

| UI Components | 55% | Custom design system + platform splits | Shared components; platform-specific safe areas, gestures |

| Native Bridges | 0% | expo-local-authentication, expo-notifications | Abstract interface defined in shared code |

Directory Structure

ecommerce-app/
├── src/
│   ├── core/
│   │   ├── api/
│   │   │   ├── client.ts          # Axios instance, interceptors, token refresh
│   │   │   ├── websocket.ts       # WebSocket client for order tracking
│   │   │   └── endpoints.ts       # Typed API endpoint definitions
│   │   ├── storage/
│   │   │   ├── mmkv.ts            # MMKV wrapper for auth tokens, preferences
│   │   │   └── watermelon.ts      # WatermelonDB schema for catalog cache
│   │   ├── navigation/
│   │   │   ├── RootNavigator.tsx  # Stack: Auth flow + Main tab navigator
│   │   │   ├── routes.ts          # Type-safe route name constants
│   │   │   └── linking.ts         # Deep link configuration
│   │   └── theme/
│   │       ├── tokens.ts          # Colors, spacing, typography scales
│   │       └── ThemeProvider.tsx  # React context theme provider
│   ├── features/
│   │   ├── auth/
│   │   │   ├── domain/
│   │   │   │   ├── AuthRepository.ts        # Interface definition
│   │   │   │   └── useCases/LoginUseCase.ts # Orchestrates biometric + API
│   │   │   ├── data/
│   │   │   │   ├── AuthRepositoryImpl.ts
│   │   │   │   └── BiometricService.ts      # expo-local-authentication wrapper
│   │   │   └── ui/
│   │   │       ├── LoginScreen.tsx
│   │   │       └── useAuthStore.ts          # Zustand slice for auth state
│   │   ├── catalog/
│   │   │   ├── domain/
│   │   │   ├── data/
│   │   │   └── ui/                          # ProductList, ProductDetail, Search
│   │   ├── cart/
│   │   │   ├── domain/
│   │   │   ├── data/
│   │   │   └── ui/                          # CartScreen, CartItem, Checkout
│   │   └── orders/
│   │       ├── domain/
│   │       ├── data/
│   │       │   └── OrderTrackingService.ts  # WebSocket subscription management
│   │       └── ui/                          # OrderList, OrderDetail (live update)
│   └── shared/
│       ├── components/
│       │   ├── PriceDisplay.tsx             # Currency formatting, shared
│       │   ├── ProductCard.tsx              # Shared catalog card component
│       │   └── SkeletonLoader.tsx           # Loading state placeholder
│       └── utils/
│           ├── currency.ts                  # Locale-aware price formatting
│           └── validation.ts               # Zod schemas for form inputs
├── android/                                 # Managed by Expo until bare workflow
├── ios/                                     # Managed by Expo until bare workflow
└── docs/
    └── adr/
        ├── ADR-001-react-native-framework.md
        ├── ADR-002-state-management-zustand.md
        └── ADR-003-watermelondb-catalog-cache.md

Platform-Specific Handling Plan

| Concern | iOS Approach | Android Approach |

|----------------------|--------------------------------------------------------|-------------------------------------------------------------|

| Navigation gestures | Enable swipe-back on stack screens (default in RN 6) | Intercept hardware back button with BackHandler in cart/checkout |

| Safe area insets | SafeAreaProvider + useSafeAreaInsets() universally | Same library; test on gesture-nav Android 10+ devices |

| Biometric login | Face ID / Touch ID via expo-local-authentication | Fingerprint / Face via same API (BiometricPrompt backing) |

| Push notifications | APNs via expo-notifications; register in app launch | FCM via same API; test FCM on physical device, not emulator |

| WebSocket (orders) | Background to foreground re-connect on AppState change | Same pattern; test app resume on aggressive OEM killers (Samsung) |

| Permissions | NSCameraUsageDescription (not needed for this app) | POST_NOTIFICATIONS permission required for API 33+ at runtime |


Performance Targets and Testing Protocol

| Metric | Target | Measurement Method | Test Device |

|-----------------------|-----------------|--------------------------------------------|--------------------------------------|

| Cold start TTI | < 2.0 seconds | Flipper plugin + manual stopwatch | Samsung Galaxy A32 (SD 720G, 4 GB) |

| Catalog scroll | 60 fps sustained| Android Studio CPU profiler, Instruments | A32 + iPhone 12 (2-year-old device) |

| Memory (steady state) | < 160 MB RSS | Android Studio Memory Profiler | A32 as worst-case |

| Order WebSocket | < 1s reconnect | Manual test: background app 30s, foreground| Both platforms |

| Checkout flow | < 3s end-to-end | Detox E2E test with performance assertion | Both reference devices |

Key implementation notes for this project:


CI/CD Pipeline Requirements


Architecture Decision Record (ADR-001)

Title: Cross-Platform Framework Selection -- React Native (Expo)

Status: Accepted

Date: [Project kickoff date]

Context:

We are building a greenfield B2C e-commerce app targeting iOS and Android with a 4-month iOS deadline. The team of 7 includes 4 senior React/TypeScript engineers, 2 junior iOS developers, and 1 Android developer. Feature requirements include standard e-commerce UI, biometric auth, push notifications, and WebSocket-driven order tracking. No Tier 3 hardware features are required.

Decision:

React Native with Expo managed workflow (migrating to bare workflow by month 3 when the team needs more control over native configuration). This choice is driven primarily by the team's React/TypeScript expertise, which eliminates a framework learning curve and is essential for meeting the 4-month deadline.

Consequences:

Alternatives Considered:

| Alternative | Rejected Because |

|-------------|-----------------|

| Flutter | Zero Dart experience on team; 3--6 month learning curve incompatible with 4-month deadline; superior rendering consistency not decisive for standard e-commerce UI |

| Native iOS + Native Android | Would require the 4 senior JS engineers to learn Swift/Kotlin; effectively doubles UI feature work; 2 junior iOS developers alone cannot deliver full iOS app in 4 months |

| KMM | Requires Kotlin expertise the team does not have; best suited for teams migrating existing native apps, not greenfield with JS-dominant team |

Revisit Condition:

Revisit this decision if: (1) Tier 3 feature requirements are added that exceed 20% of the backlog (e.g., AR product visualization, custom payment hardware integration), or (2) scroll performance on the catalog screen cannot be maintained at 60 fps on the Galaxy A32 reference device after optimization, or (3) team composition shifts to > 50% native iOS/Android engineers within the next 12 months.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.