Skip to main content

Module Integration

1. Prerequisites

Before starting Module integration, ensure you have completed the following:

2. Project Structure

This section uses the Conch-integrated example_external_module project as an example and explains how to integrate as a Module on iOS and Android.

Overall project structure:

root/
├── example_external_module/ # Conch Module project with Conch integration configured
├── example_ios_module_host/ # iOS host app example
└── example_module_host_android/ # Android host app example

3. Configure Conch Module pubspec.yaml

After SDK integration and Conch dependency configuration, add Module-related settings in pubspec.yaml so the project can be integrated by native apps as a Module.

# Key configuration: identify this as a Flutter Module
flutter:
module:
androidX: true
androidPackage: com.example.example_external_module
iosBundleIdentifier: com.example.exampleExternalModule

Configuration notes:

  • androidX: true: Enable AndroidX support for compatibility with modern Android projects
  • androidPackage: Android package name; follow the same naming convention as the host app
  • iosBundleIdentifier: iOS Bundle identifier

4. iOS Integration

4.1 CocoaPods Integration

4.1.1 Configure iOS Host App Podfile

Add Flutter Module integration configuration in the host app's Podfile:

# Relative path to the Conch Module project (adjust as needed)
flutter_application_path = '../example_external_module'

# Load Flutter podhelper
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')

target 'YourAppTargetName' do # Replace with your iOS target name
# ... other Pods ...

install_all_flutter_pods(flutter_application_path)
end

post_install do |installer|
flutter_post_install(installer) if defined?(flutter_post_install)
end

Configuration notes:

  • flutter_application_path: Relative path to the Flutter Module project
  • install_all_flutter_pods: Installs all Flutter Module dependencies automatically
  • flutter_post_install: Runs Flutter-specific post-install configuration

Notes:

  • Ensure the Flutter Module pubspec.yaml Module configuration is correct
  • If the Flutter Module uses local path dependencies, configure additional paths in the Podfile
  • Run pod install on first integration to verify configuration

4.1.2 iOS Build Flow

# 1. Build Flutter Module as iOS Framework
cd example_external_module
flutter clean
flutter pub get
flutter build ios-framework --no-debug --no-profile

# 2. Install iOS app dependencies
cd ../example_ios_module_host
pod install

# 3. Build iOS app

5. Android Integration

5.1 Repository Configuration

Flutter Android projects typically fetch dependencies from Google Maven (google()) and Maven Central (mavenCentral()).

To build correctly and use Conch hotfix capabilities, configure additional local Conch engine repositories and the Shiply repository in build.gradle.

5.1.1 Configure Android Host App settings.gradle.kts

Add required repository configuration in the host app's settings.gradle.kts:

Important: Add the Conch engine repository and Shiply repository, otherwise Conch dependencies may not resolve.

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()

// Flutter AAR local repository path
maven { url = uri("${rootDir}/../example_external_module/build/host/outputs/repo") }

// Conch engine repository
// Legacy: Conch SDK distributed via zip—configure local path (replace with actual path)
// maven { url = uri("{YOUR_PATH}/conch-flutter/bin/conch/maven") }
// New (Conch 1.7.0+): Conch-Flutter SDK via Git with Maven artifact repo (important)
maven { url = uri("https://maven.cnb.cool/tencent-tds/conch-release-maven/-/packages/") }

// Shiply repository (important)
maven { url = uri("https://maven.cnb.cool/tencent-tds/shiply-public/-/packages/") }
}
}

5.1.2 Configure app/build.gradle.kts

Add Flutter AAR dependency in the app module's build.gradle.kts:

dependencies {
// Flutter AAR dependency
implementation("com.example.example_external_module:flutter_release:1.0")

// Other existing dependencies
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
// ...
}

5.1.3 Android Build Flow

# 1. Build Flutter Module as AAR
cd example_external_module
flutter clean
flutter pub get
flutter build aar --no-debug --no-profile

# 2. Build Android app
cd ../example_module_host_android
./gradlew assembleRelease
Was this page helpful?