Integrate SDK via SPM

This topic introduces how to integrate the IAPMiniProgram SDK via Swift Package Manager (SPM).

Prerequisites

Item

Requirement

Xcode

15.0+

iOS deployment target

12.0+

SDK version

XCFramework version ≥ 2.83.0.99

See SDK release notes.

Integration procedures

Step 1. Download SDK resources

  1. Open the MiniProgram platform, sign in with your account
  2. Go to the SDK download page, select the SDK version that matches your project, and download it. See the following figure as an example.

image

  1. After unzipping the SDK package, the directory structure is as follows:
    Almost each folder corresponds to one SDK component (e.g. Operation, Google Map) . For more information, see the Integrate SDK components topic.
copy
IAPMiniProgram/
├── IAPMiniProgram/                    # core module(required)
│   ├── framework/                     # xcframework binary
│   └── resource/                      # bundle resources
├── IAPMiniProgram_Operation/          # operation module(optional)
├── IAPMiniProgram_AppleMap/           # Apple Map(optional)
├── IAPMiniProgram_GoogleMap/          # Google Map(optional)
├── IAPMiniProgram_Video/              # Video(optional)
├── IAPMiniProgram_Media/              # Media/audio(optional)
├── IAPMiniProgram_Lottie/             # Lottie animation(optional)
├── IAPMiniProgram_Bluetooth/          # Bluetooth(optional)
├── IAPMiniProgram_BioAuth/            # biometric authentication(optional)
├── IAPMiniProgram_Legacy/             # legacy feature compatibility(optional)
├── IAPMiniProgram_ACTranslation/      # translation(optional)
├── IAPMiniProgram_ACManifest/         # Manifest(optional)
├── IAPMiniProgram_Inspection/         # inspection(optional)
├── IAPMiniProgram_Localization/       # multil-lang localization(optional)
├── IAPMiniProgram_Optimizations/      # Optimization(optional)
├── ThirdParty/                        # third-party dependencies
└── IAPMiniProgram-SPM/                # SPM package(core)
    ├── Package.swift                  # SPM package defintion
    ├── Scripts/
    │   └── sync_from_local.sh         # xcframework output synchronization shell script
    └── Sources/                       # wrapper target source code + Resources/(bundle, with the package)

Step 2. Synchronize SDK output to SPM package

Synchronize the xcframeworks of each module to the IAPMiniProgram-SPM/xcframeworks/ directory:

copy
cd IAPMiniProgram-SPM
bash Scripts/sync_from_local.sh --execute

Step 3. Add the local SPM package to the Xcode project

  1. Open your app's Xcode project.
  2. Clike File → Add Package Dependencies...
  3. On the bottom-left corner, click Add Local...
  4. Choose IAPMiniProgram-SPM ,click Add Package to add the local SPM package to the Xcode project.

Step 4. Select modules to integrate

In Xcode, select the modules that you need to integrate in the SPM package product selection dialog. See the following SPM integration module overview section. Different module combination realizes various integration scenarios.

Integration scenarios

The following table list some common SPM integration scenarios:

Scenario

Modules to select

Minimal integration (integrate only the core/required module)

IAPMiniProgramCore

Core integration, video, and media integration

IAPMiniProgramCore, IAPMiniProgramVideo, IAPMiniProgramMedia

Full integration

Select all modules

Step 5. Build & Run

Connect the device, compile and run.

Step 6. (Conditional) Upgrade SDK version

If you need to upgrade the SDK version, see the Upgrade SDK version topic.

SPM integration module overview

The modules to integrate includes the a core/required module, and a set of optional sub-modules:

  • Core/required module: is IAPMiniProgramCore, which must be integrated always. This realizes the minimal integration, which equals to pod 'IAPMiniProgram'.
  • Sub-modules: are all optional. They can be integrated on demand, e.g. IAPMiniProgram_Video. Almost each sub-module corresponds to one SDK component (e.g. Operation, Google Map) . For more information, see the Integrate SDK components topic.

Core/required module

Module name

Capability

Core xcframework

Core bundle

IAPMiniProgramCore

Core/required module. Must be integrated always.

  • AriverKernel
  • AriverApp
  • AriverRuntime
  • AriverApi
  • AriverConfig
  • AriverDebug
  • AriverDevice
  • AriverDeviceCore
  • AriverFileManager
  • AriverLogger
  • AriverResource
  • AriverSecurity
  • AriverWebSocket
  • ACGriverCore
  • GRVAppContainer
  • GriverInit
  • GriverInterface
  • GriverUtilities
  • GriverDebug
  • GriverRuntimeResources
  • IAPMiniProgram
  • IAPConfiguration
  • IAPConfigurationStarter
  • IAPInstanceInfo
  • IAPJSONKit
  • IAPLogLite
  • IAPLogLiteDiagnose
  • IAPLogLiteStarter
  • IAPProviderManager
  • IAPRPCServiceLite
  • IAPSafeMode
  • IAPSecurityGuardLite
  • IAPTimeElapse
  • IAPTinyLogger
  • IAPWalletAPI
  • ACCommonLibraryLite
  • SocketRocket
  • ZipArchive
  • AriverKernel
  • AriverRuntime
  • GriverInterface
  • GriverResource
  • GriverRuntime
  • GriverRuntimeOptional
  • IAPConfiguration
  • IAPMiniProgramSDK
  • AriverApp
  • AriverFileManager
  • AriverResource
  • IAPInstanceInfo
  • IAPJSONKit
  • IAPLogLite
  • IAPLogLiteDiagnose
  • IAPLogLiteStarter
  • IAPProviderManager
  • IAPRPCServiceLite
  • IAPSafeMode

Sub-modules

Sub-module name

Capability

Extra xcframework

Extra bundle

IAPMiniProgramOperation

Operation module (e.g. data monitoring, user interaction, rating, handling feedback and comments)

  • GriverOperation
  • IAPConnectACLAdaptor
  • IAPConnectInterface
  • IAPConnectManager
  • IAPConnectMultiLanguage
  • IAPConnectPluginTransitional
  • IAPConnectManager
  • IAPConnectPlugin
  • IAPConnectMultiLanguage

IAPMiniProgramAppleMap

Apple map

  • GriverBaseMap
  • GriverAppleMap
  • GriverMap

IAPMiniProgramGoogleMap

Google map

  • GriverBaseMap
  • GriverGoogleMap
  • GriverMap

IAPMiniProgramVideo

Play videos

  • GriverVideo
  • GriverVideo

IAPMiniProgramMedia

Play audios

  • GriverMedia
  • GriverVideo
  • GriverMedia

IAPMiniProgramLottie

Lottie animation

  • GriverLottie

NA

IAPMiniProgramBluetooth

Bluetooth

  • GriverBluetooth

NA

IAPMiniProgramBioAuth

Biometric authentication

  • GriverBioAuth

NA

IAPMiniProgramLegacy

Implement Alipay Connect features

  • IAPConnect
  • IAPConnectInterface
  • ACGriverAdapter
  • ACGriverAdapter
  • IAPConnectManager

IAPMiniProgramACTranslation

Implement translation capabilities

  • GriverTranslation
  • IAPConnectInterface
  • IAPConnectManager
  • IAPConnectMultiLanguage
  • IAPConnectPluginTranslation
  • GriverTranslation
  • IAPConnectManager
  • IAPConnectPluginTranslation
  • IAPConnectMultiLanguage

IAPMiniProgramACManifest

Mini Program manifest / resource management

  • GriverManifest
  • IAPManifestResource
  • IAPResourceManager
  • IAPResourceManager

IAPMiniProgramInspection

Implement inspection capabilities

  • GriverInspection
  • GriverInspection

IAPMiniProgramLocalization

Multil-language localization

NA

  • GriverLocalization

Related information