Enterprise Mobile Application Studio (EMAS) provides WindVane and uni-app miniapp containers that you can embed in a native iOS app. This topic describes how to add the required dependencies and initialize the container so that your app can load and run miniapps.
Prerequisites
Before you begin, ensure that you have:
The AccessKey, SecretKey, and App Code of a native app. For more information, see the Configure an app topic in the Application Open Platform (for platform operators) chapter of the User Guide.
The domain name of Application Open Platform. The domain name of the demo environment is
poc.superapp-intl.com.
Step 1: Add dependencies
-
Add the CocoaPods repositories.
pod repo add superapp-intl-emas-ios-emas-specs https://gitlab-console.superapp-intl.com/emas-ios/emas-specs.git pod repo add superapp-intl-emas-ios-emas-specs-thirdpart https://gitlab-console.superapp-intl.com/emas-ios/emas-specs-thirdpart.git -
In the Podfile in the project root directory, configure the CocoaPods sources.
The SDKs for miniapp containers are distributed through a private CocoaPods repository. Contact your O&M engineer to get the account credentials required to authenticate with the private source.
source 'https://gitlab-console.superapp-intl.com/emas-ios/emas-specs.git' source 'https://gitlab-console.superapp-intl.com/emas-ios/emas-specs-thirdpart.git' -
In the Podfile, add the dependencies for the miniapp container.
use_frameworks! # Required for both WindVane and uni-app containers pod 'EMASServiceManager' pod 'EMASMiniAppAdapter' # Required only for the WindVane miniapp container pod 'EMASWindVaneMiniApp' # Required only for the uni-app miniapp container pod 'EMASUniappMiniApp'Add
EMASWindVaneMiniApp,EMASUniappMiniApp, or both, depending on which container types your app integrates. TheuseWindVaneanduseUniAppflags in Step 2 must match the pods you include here.
Step 2: Initialize the container
Call the initialization code in application(_:didFinishLaunchingWithOptions:) to make sure the miniapp container is ready before any other app functionality runs.
// Initialize the miniapp container
EMASMiniAppInitConfig *miniAppInitConfig = [EMASMiniAppInitConfig new];
miniAppInitConfig.useUniApp = YES; // Set to YES if you added EMASUniappMiniApp
miniAppInitConfig.useWindVane = YES; // Set to YES if you added EMASWindVaneMiniApp
miniAppInitConfig.accessKey = @"ZXZ8****"; // AccessKey from Application Open Platform
miniAppInitConfig.secretKey = @"3PNJxKtf7/eqUohlG3bI****"; // SecretKey from Application Open Platform
miniAppInitConfig.host = @"emas.example.com"; // Domain name of Application Open Platform. The demo environment domain is emas-publish-intl.emas-poc.com.
miniAppInitConfig.appCode = @"161160615860445224****"; // App Code from Application Open Platform
EMASMiniAppServiceImpl *miniAppService = [EMASMiniAppServiceImpl new];
[miniAppService initialize:miniAppInitConfig];
[[EMASServiceManager sharedInstance] registerServiceProtocol:@"EMASMiniAppService" IMPClass:@"EMASMiniAppServiceImpl" target:miniAppService];
// Optional: register additional services for WindVane features.
// Uncomment the lines for any features you want to enable.
//[[EMASServiceManager sharedInstance] registerServiceProtocol:@"EMASMiniAppFavoriteService" IMPClass:@"EMASMiniAppFavoriteServiceImpl" target:[EMASMiniAppFavoriteService new]]; // Favorites
//[[EMASServiceManager sharedInstance] registerServiceProtocol:@"EMASUserInfoService" IMPClass:@"EMASUserInfoServiceImpl" target:[EMASUserInfoServiceImpl new]]; // Associated users
//[[EMASServiceManager sharedInstance] registerServiceProtocol:@"EMASMiniAppURLService" IMPClass:@"EMASMiniAppURLServiceImpl" target:[EMASMiniAppURLServiceImpl new]]; // URL interception
Troubleshooting
-
Building for iOS Simulator on Apple Silicon (M series)
When running on a simulator on a Mac with an Apple Silicon M-series chip, select the simulator labeled Rosetta in Product > Destination.
Install Rosetta if not already installed:
Install Rosetta:
sudo softwareupdate --install-rosetta --agree-to-licenseIf you run without Rosetta and see the error Building for 'iOS-simulator', but linking in object file built for iOS, go to Build Settings > Excluded Architectures and add Any iOS Simulator SDK: arm64. If a third-party
.frameworkor.afile produces an x86_64 Undefined symbol: _OBJC_CLASS_$_ error, go to Build Settings > Other Linker Flags and add -ld64, then select the Rosetta-labeled simulator under Product > Destination. -
Sandbox: rsync.samba deny error in Xcode 15
Xcode 15 introduced
ENABLE_USER_SCRIPT_SANDBOXING. If you see the error Sandbox: rsync.samba deny, go to Build Settings > User script sandboxing and set the value to No.
API reference
For more information, see API referenece.