### Install Tuist Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/IntegrationTests/README.md Install the Tuist dependency manager using Homebrew. ```bash brew install tuist ``` -------------------------------- ### mParticle SDK 7 Kit Dependencies Example Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/MIGRATING.md Example Podfile configuration for mParticle SDK version 7 and earlier, requiring all kit versions to match the core SDK version. ```ruby pod 'mParticle-Apple-SDK', '7.16.2' pod 'mParticle-Appboy', '7.16.2' pod 'mParticle-BranchMetrics', '7.16.2' ``` -------------------------------- ### Start Metro Server Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/RNExample/README.md Start Metro, the JavaScript bundler for React Native. Use npm or Yarn. ```bash # using npm npm start # OR using Yarn yarn start ``` -------------------------------- ### Run Android Application Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/RNExample/README.md Start your Android app using npm or Yarn after Metro Bundler is running. ```bash # using npm npm run android # OR using Yarn yarn android ``` -------------------------------- ### Run iOS Application Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/RNExample/README.md Start your iOS app using npm or Yarn after Metro Bundler is running. ```bash # using npm npm run ios # OR using Yarn yarn ios ``` -------------------------------- ### Initialize Braze and Set Instance for mParticle Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/braze/braze-14/README.md Initialize the Braze SDK with your API key and endpoint, then set the Braze instance and notification handling preference before starting mParticle. This is crucial for iOS push-launch tracking. ```swift import BrazeKit import mParticle_Braze let configuration = Braze.Configuration( apiKey: "[YOUR_BRAZE_API_KEY]", endpoint: "[YOUR_BRAZE_ENDPOINT]" ) let braze = Braze(configuration: configuration) MPKitBraze.setBrazeInstance(braze) MPKitBraze.setShouldDisableNotificationHandling(true) // Start mParticle after this. ``` -------------------------------- ### Verify Singular Integration in Console Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/singular/singular-12/README.md After installation, rebuild and launch your app. Check the Xcode console for this message to confirm the Singular kit is included when the mParticle log level is Debug or higher. ```bash Included kits: { Singular } ``` -------------------------------- ### Add Kits with CocoaPods Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/README.md Integrate mParticle kits with the core SDK using CocoaPods by adding the respective pod specifications to your Podfile. This example includes Braze, Branch Metrics, and Localytics kits. ```ruby target '' do pod 'mParticle-Braze-14', '~> 9' pod 'mParticle-BranchMetrics-3', '~> 9' pod 'mParticle-Localytics-7', '~> 9' end ``` -------------------------------- ### Verify Adjust Integration in Xcode Console Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/adjust/adjust-5/README.md After installation, rebuild and launch your app. With the mParticle log level set to Debug or higher, check the Xcode console for confirmation that the Adjust kit is included. ```bash Included kits: { Adjust } ``` -------------------------------- ### Verify Apptimize Integration in Xcode Console Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/apptimize/apptimize-3/README.md After installation, rebuild and launch your app. Check the Xcode console for this message with the mParticle log level set to Debug or higher to confirm the Apptimize kit is included. ```bash Included kits: { Apptimize } ``` -------------------------------- ### Update Identity API for Customer ID (SDK v8) Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/MIGRATING.md Example of setting a customer ID using the new setIdentity API with MPIdentityCustomerId in Apple SDK v8. ```objectivec MPIdentityApiRequest *identityRequest = [MPIdentityApiRequest requestWithUser:currentUser]; [identityRequest setIdentity:@"123456" identityType:MPIdentityCustomerId]; [[[MParticle sharedInstance] identity] modify:identityRequest completion:identityCallback]; ``` -------------------------------- ### Record API Requests with WireMock Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/IntegrationTests/README.md Execute the script to record mParticle SDK API requests using WireMock. This process involves building the test app, starting a simulator, and launching the app to capture traffic. ```bash ./run_wiremock_recorder.sh ``` -------------------------------- ### Add Branch Metrics Kit via CocoaPods Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/branchmetrics/branchmetrics-3/README.md Add the mParticle-BranchMetrics kit dependency to your app's Podfile for installation using CocoaPods. ```ruby pod 'mParticle-BranchMetrics', '~> 9.0' ``` -------------------------------- ### Verify Apptentive Integration in Xcode Console Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/apptentive/apptentive-6/README.md After installation, rebuild and launch your app. With the mParticle log level set to Debug or higher, check your Xcode console for this output to confirm the Apptentive kit is included. ```bash Included kits: { Apptentive } ``` -------------------------------- ### Verify OneTrust Integration Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/onetrust/onetrust/README.md After installation and rebuilding the app, check the Xcode console logs for confirmation that the OneTrust kit is included. This requires the mParticle log level to be set to Debug or higher. ```bash Included kits: { OneTrust } ``` -------------------------------- ### Update Identity API for Customer ID (SDK v7) Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/MIGRATING.md Example of setting a customer ID using the setUserIdentity API in Apple SDK v7. ```objectivec MPIdentityApiRequest *identityRequest = [MPIdentityApiRequest requestWithUser:currentUser]; [identityRequest setUserIdentity:@"123456" identityType:MPUserIdentityCustomerId]; [[[MParticle sharedInstance] identity] modify:identityRequest completion:identityCallback]; ``` -------------------------------- ### Add CleverTap Kit Dependency via CocoaPods Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/clevertap/clevertap-7/README.md Add the mParticle-CleverTap kit dependency to your app's Podfile for installation using CocoaPods. ```ruby pod 'mParticle-CleverTap', '~> 9.0' ``` -------------------------------- ### Add Adjust Kit Dependency via CocoaPods Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/adjust/adjust-5/README.md Add the mParticle-Adjust kit dependency to your application's Podfile for installation using CocoaPods. ```ruby pod 'mParticle-Adjust', '~> 9.0' ``` -------------------------------- ### Verify Radar Kit Inclusion Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/radar/radar-3/README.md After installation, rebuild and launch your app. With the mParticle log level set to Debug or higher, check the Xcode console for this output to confirm the Radar kit is included. ```bash Included kits: { Radar } ``` -------------------------------- ### Initialize mParticle SDK with ATT Status Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/MIGRATING.md Set the ATT status during SDK initialization using `MParticleOptions`. This ensures the status is captured from the start. The `attStatus` property expects an `NSNumber` representing the raw value of `ATTrackingManagerAuthorizationStatus`. ```swift let options = MParticleOptions(key: "REPLACE WITH APP KEY", secret: "REPLACE WITH APP SECRET") options.attStatus = NSNumber.init(value: ATTrackingManager.trackingAuthorizationStatus.rawValue) MParticle.sharedInstance().start(with: options) ``` -------------------------------- ### Verify CleverTap Integration in Xcode Console Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/clevertap/clevertap-7/README.md After installation, rebuild and launch your app. With the mParticle log level set to Debug or higher, check your Xcode console for this output to confirm the CleverTap kit is included. ```bash Included kits: { CleverTap } ``` -------------------------------- ### Verify Optimizely Integration in Xcode Console Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/optimizely/optimizely-5/README.md After installation and rebuilding your app, check the Xcode console for this message to confirm the Optimizely kit is included. Ensure your mParticle log level is set to Debug or higher. ```bash Included kits: { Optimizely } ``` -------------------------------- ### Verify AppsFlyer Integration in Xcode Console Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/appsflyer/appsflyer-6/README.md After installation, rebuild and launch your app. With the mParticle log level set to Debug or higher, check the Xcode console for confirmation that the AppsFlyer kit is included. ```bash Included kits: { AppsFlyer } ``` -------------------------------- ### Verify Rokt Integration in Xcode Console Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/rokt/rokt/README.md After installation and rebuilding your app, check the Xcode console logs with mParticle's log level set to Debug or higher to confirm the Rokt kit is included. ```bash Included kits: { Rokt } ``` -------------------------------- ### Verify Firebase Integration in Xcode Console Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/google-analytics-firebase/firebase-12/README.md After installation, rebuild and launch your app. With the mParticle log level set to Debug or higher, check the Xcode console for confirmation of the Firebase kit inclusion. ```bash Included kits: { Firebase } ``` -------------------------------- ### Verify Branch Metrics Integration in Logs Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/branchmetrics/branchmetrics-3/README.md After installation and rebuilding the app, check the Xcode console for a log message indicating that the BranchMetrics kit is included. This requires the mParticle log level to be set to Debug or higher. ```bash Included kits: { BranchMetrics } ``` -------------------------------- ### Verify Leanplum Integration in Xcode Console Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/leanplum/leanplum-6/README.md After installation and rebuilding your app, check the Xcode console for this message to confirm the Leanplum kit is included. Ensure your mParticle log level is set to Debug or higher. ```bash Included kits: { Leanplum } ``` -------------------------------- ### Verify Adobe Integration in Xcode Console Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/adobe/adobe-5/README.md After installation, rebuild and launch your app. With the mParticle log level set to Debug or higher, check the Xcode console for the included kits. This confirms the Adobe integration is active. ```bash Included kits: { Adobe } ``` -------------------------------- ### Initialize mParticle SDK Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/rokt-sdk-plus/rokt-sdk-plus-ios/README.md Initialize the mParticle SDK from application(_:didFinishLaunchingWithOptions:) with your App Key and Secret. Do not defer startup using dispatch_async. ```swift import mParticle_Apple_SDK func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { let options = MParticleOptions(key: "<<>>", secret: "<<>>") MParticle.sharedInstance().start(with: options) return true } ``` -------------------------------- ### Build mParticle XCFramework Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/SwiftExample/README.md Use these bash commands to build the mParticle XCFramework from the repository root. Ensure the build scripts are executable before running. ```bash # Make the build scripts executable chmod +x ./Scripts/make_artifacts.sh chmod +x ./Scripts/xcframework.sh # Build the frameworks ./Scripts/make_artifacts.sh ``` -------------------------------- ### Add CocoaPods Dependency Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/urbanairship/urbanairship-20/README.md Add the mParticle-UrbanAirship kit dependency to your app's Podfile for CocoaPods installation. ```ruby pod 'mParticle-UrbanAirship', '~> 9' ``` -------------------------------- ### Build and Test mParticle SDK Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/CONTRIBUTING.md Run this command to build and execute the test suite for the mParticle Apple SDK. Ensure all tests pass before submitting a Pull Request. ```bash xcodebuild -workspace mParticle-Apple-SDK.xcworkspace -scheme mParticle-Apple-SDK-iOS test ``` -------------------------------- ### Add Radar Kit Dependency (CocoaPods) Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/radar/radar-3/README.md Add the Radar kit dependency to your app's Podfile for installation via CocoaPods. ```ruby pod 'mParticle-Radar', '~> 9.0' ``` -------------------------------- ### Initialize mParticle SDK in Swift Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/README.md Initialize the mParticle SDK with your app key, secret, and an initial identity request. This should be called in `application:didFinishLaunchingWithOptions:`. ```swift import mParticle_Apple_SDK func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. let mParticleOptions = MParticleOptions(key: "<<>>", secret: "<<>>") //Please see the Identity page for more information on building this object let request = MPIdentityApiRequest() request.email = "email@example.com" mParticleOptions.identifyRequest = request mParticleOptions.onIdentifyComplete = { (apiResult, error) in NSLog("Identify complete. userId = %@ error = %@", apiResult?.user.userId.stringValue ?? "Null User ID", error?.localizedDescription ?? "No Error Available") } //Start the SDK MParticle.sharedInstance().start(with: mParticleOptions) return true } ``` -------------------------------- ### Run SDK Size Report Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Tests/SizeReport/README.md Execute the size report script. Use the `--json` flag for machine-readable output suitable for CI integration. ```bash ./measure_size.sh # Human-readable output ./measure_size.sh --json # JSON output for CI ``` -------------------------------- ### Initialize mParticle SDK in Objective-C Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/README.md Initialize the mParticle SDK with your app key, secret, and an initial identity request. This should be called in `application:didFinishLaunchingWithOptions:`. ```objective-c - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { MParticleOptions *mParticleOptions = [MParticleOptions optionsWithKey:@"REPLACE ME" secret:@"REPLACE ME"]; //Please see the Identity page for more information on building this object MPIdentityApiRequest *request = [MPIdentityApiRequest requestWithEmptyUser]; request.email = @"email@example.com"; mParticleOptions.identifyRequest = request; mParticleOptions.onIdentifyComplete = ^(MPIdentityApiResult * _Nullable apiResult, NSError * _Nullable error) { NSLog(@"Identify complete. userId = %@ error = %@", apiResult.user.userId, error); }; [[MParticle sharedInstance] startWithOptions:mParticleOptions]; return YES; } ``` -------------------------------- ### mParticle SDK 8 Kit Dependencies Recommendation Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/MIGRATING.md Recommended Podfile configuration for mParticle SDK version 8 and later, allowing for decoupled kit versions. Update to the latest versions as needed. ```ruby pod 'mParticle-Apple-SDK', '~> 8.0' pod 'mParticle-Appboy', '~> 8.0' pod 'mParticle-BranchMetrics','~> 8.0' ``` -------------------------------- ### Initial Recording of API Requests Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/IntegrationTests/README.md This section outlines the initial steps for recording API requests using WireMock. It involves writing test code, running the recorder script, and filtering the generated mappings. -------------------------------- ### Display Rokt Shoppable Ads Placement (Objective-C) Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/rokt/rokt/README.md Objective-C implementation for displaying a Rokt Shoppable Ads placement, including user attributes and an event handler for placement readiness. ```objective-c [[MParticle sharedInstance].rokt selectShoppableAds:@"ShopView" attributes:@{@"email": @"user@example.com"} config:nil onEvent:^(RoktEvent * _Nonnull event) { if ([event isKindOfClass:[RoktPlacementReady class]]) { // Placement is ready } }]; ``` -------------------------------- ### Run SwiftLint Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/CONTRIBUTING.md Execute SwiftLint to check for code style and linting issues. This command should be run before submitting your Pull Request. ```bash swiftlint ``` -------------------------------- ### Add Kits with Swift Package Manager Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/README.md Integrate specific mParticle kits alongside the core SDK using Swift Package Manager by adding each kit's repository URL separately. ```text https://github.com/mparticle-integrations/mparticle-apple-integration-branchmetrics-3 https://github.com/mparticle-integrations/mparticle-apple-integration-braze-14 ``` -------------------------------- ### Verify Urban Airship Kit Inclusion Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/urbanairship/urbanairship-20/README.md After installation, rebuild and launch your app. Check the Xcode console logs for confirmation of the UrbanAirship kit inclusion when the mParticle log level is set to Debug or higher. ```bash Included kits: { UrbanAirship } ``` -------------------------------- ### Begin Approximate Location Tracking Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/MIGRATING.md Use this Objective-C snippet to initiate location tracking with reduced accuracy. Ensure you have the necessary user permissions. ```objective-c [[MParticle sharedInstance] beginLocationTracking:kCLLocationAccuracyReduced minDistance:1000]; ``` -------------------------------- ### Verify Localytics Integration in Xcode Console Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/localytics/localytics-7/README.md After installation and rebuilding the app, check the Xcode console for this output to confirm the Localytics kit is included. Ensure the mParticle log level is set to Debug or higher. ```bash Included kits: { Localytics } ``` -------------------------------- ### Import mParticle SDK in Objective-C Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/README.md Import the mParticle SDK using either the module or traditional import syntax, depending on your project configuration. ```objective-c @import mParticle_Apple_SDK; // Apple recommended syntax, but requires "Enable Modules (C and Objective-C)" in pbxproj #import // Works when modules are not enabled #import #import "mParticle.h" ``` -------------------------------- ### Run Integration Tests Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/IntegrationTests/README.md Execute the verification script to run full end-to-end integration tests. This script automates several steps including project regeneration, environment reset, and test execution. ```bash ./run_clean_integration_tests.sh ``` -------------------------------- ### Clone mParticle Apple SDK Repository Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/README.md Clone the mParticle Apple SDK repository from GitHub to access the sample project and source code. ```bash git clone https://github.com/mParticle/mparticle-apple-sdk.git ``` -------------------------------- ### Verify Kochava Kit Integration in mParticle Logs Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/kochava/kochava-9/README.md When the mParticle log level is set to Debug or higher, you can verify the Kochava kit integration by looking for the 'Included kits: { Kochava }' message in the logs. ```bash Included kits: { Kochava } ``` -------------------------------- ### Add Core SDK with Swift Package Manager Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/README.md Integrate the core mParticle SDK using Swift Package Manager by adding the repository URL to Xcode. ```text https://github.com/mParticle/mparticle-apple-sdk ``` -------------------------------- ### Display Rokt Shoppable Ads Placement Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/rokt/rokt/README.md Initiate the display of a Rokt Shoppable Ads placement by providing the placement ID and user attributes. A callback handles events, such as when the placement is ready. ```swift MParticle.sharedInstance().rokt.selectShoppableAds("ShopView", attributes: ["email": "user@example.com"], config: nil) { event in if event is RoktEvent.PlacementReady { // Placement is ready } } ``` -------------------------------- ### Verify ComScore Kit Integration in Xcode Console Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/comscore/comscore-6/README.md After installation and rebuilding the app, check the Xcode console for confirmation that the ComScore kit is included. This requires the mParticle log level to be set to Debug or higher. ```bash Included kits: { ComScore } ``` -------------------------------- ### Generate Xcode Project with Tuist Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/IntegrationTests/README.md Navigate to the IntegrationTests directory and generate the Xcode project using Tuist. This command creates the necessary project files for building and running tests. ```bash cd IntegrationTests tuist generate ``` -------------------------------- ### Select mParticle Rokt Placements Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/rokt-sdk-plus/rokt-sdk-plus-ios/README.md Use selectPlacements to configure and display Rokt placements. Provide placement type, user attributes, and embedded views. The completion handler is called when the placement is ready. ```swift MParticle.sharedInstance().rokt.selectPlacements( "checkout", attributes: ["email": "user@example.com"], embeddedViews: ["Location1": embeddedView], config: nil ) { event in if event is RoktEvent.PlacementReady { // Placement is ready } } ``` -------------------------------- ### Subscribe to global Rokt events (Swift) Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/MIGRATING.md In Swift, utilize the `globalEvents` method to listen for global Rokt events. Use optional casting (`as?`) to safely access specific event types like `RoktEvent.InitComplete` and check the `success` property for initialization status. ```Swift MParticle.sharedInstance().rokt.globalEvents { event in if let initEvent = event as? RoktEvent.InitComplete { if initEvent.success { // Rokt SDK initialized successfully } } } ``` -------------------------------- ### Select Placements Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/rokt/rokt/README.md This method is used to select and display Rokt placements on your app. It allows for custom attributes and embedded views, and provides a callback for placement readiness. ```APIDOC ## Select Placements ### Description Select and display Rokt placements within your application. This function allows for the specification of placement names, custom attributes, and embedded views, with a callback to handle placement readiness events. ### Method Signature ```swift MParticle.sharedInstance().rokt.selectPlacements("checkout", attributes: ["email": "user@example.com"], embeddedViews: ["Location1": embeddedView], config: nil) { event in if event is RoktEvent.PlacementReady { // Placement is ready } } ``` ### Parameters - **placementName** (String) - The name of the Rokt placement to select. - **attributes** (Dictionary) - Custom attributes to pass with the placement request. - **embeddedViews** (Dictionary) - A dictionary mapping placement locations to their corresponding embedded views. - **config** (RoktConfig?) - Optional configuration for the Rokt placement. - **onEvent** (Callback) - A closure that is called when a Rokt event occurs, such as `RoktEvent.PlacementReady`. ``` -------------------------------- ### Verify Firebase GA4 Kit Integration Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/google-analytics-firebase-ga4/firebase-ga4-12/README.md After installation and rebuilding your app, check the Xcode console for this log message to confirm the Firebase GA4 kit is included. This requires the mParticle log level to be set to Debug or higher. ```bash Included kits: { FirebaseGA4 } ``` -------------------------------- ### Update Direct Dependency Target Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/MIGRATING.md Migrate from the 'mParticle-Apple-SDK-NoLocation' product to the standard 'mParticle-Apple-SDK' product for direct dependencies. ```swift dependencies: [ .package(url: "https://github.com/mParticle/mparticle-apple-sdk", from: "8.0.0") ], targets: [ .target( name: "MyApp", dependencies: [ .product(name: "mParticle-Apple-SDK-NoLocation", package: "mParticle-Apple-SDK") ] ) ] ``` ```swift dependencies: [ .package(url: "https://github.com/mParticle/mparticle-apple-sdk", from: "9.0.0") ], targets: [ .target( name: "MyApp", dependencies: [ .product(name: "mParticle-Apple-SDK", package: "mParticle-Apple-SDK") ] ) ] ``` -------------------------------- ### Extract mParticle XCFramework Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/SwiftExample/README.md Unzip the generated mParticle XCFramework zip file into the Frameworks directory. ```bash unzip mParticle_Apple_SDK.xcframework.zip -d ./Frameworks ``` -------------------------------- ### Add OneTrust Kit via Swift Package Manager Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/onetrust/onetrust/README.md Specify the OneTrust SDK as a direct dependency using .exact version matching. Ensure the version aligns with your OneTrust configuration. ```swift let mParticleVersion: Version = "9.0.0" .package( url: "https://github.com/mparticle-integrations/mp-apple-integration-onetrust", .upToNextMajor(from: mParticleVersion) ), .package( url: "https://github.com/Zentrust/OTPublishersHeadlessSDK", .exact("202502.1.0") // Use the version from your OneTrust UI ), .package( url: "https://github.com/Zentrust/OTPublishersHeadlessSDKtvOS", .exact("202502.1.0") // Must match your iOS SDK version ), ``` -------------------------------- ### Subscribe to global Rokt events (Objective-C) Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/MIGRATING.md Use the new `globalEvents:` method to subscribe to global Rokt events. This method allows you to receive events not tied to a specific view, such as `InitComplete`. Ensure proper type checking for specific events like `RoktInitComplete` and check the `success` property. ```Objective-C [[MParticle sharedInstance].rokt globalEvents:^(RoktEvent * _Nonnull event) { if ([event isKindOfClass:[RoktInitComplete class]]) { RoktInitComplete *initEvent = (RoktInitComplete *)event; if (initEvent.success) { // Rokt SDK initialized successfully } } }]; ``` -------------------------------- ### Select Rokt Placement with Attributes and Embedded Views Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/rokt/rokt/README.md Use this Swift function to select a Rokt placement, providing placement ID, user attributes, embedded views, and an optional configuration. A callback is provided to handle placement-ready events. ```swift MParticle.sharedInstance().rokt.selectPlacements("checkout", attributes: ["email": "user@example.com"], embeddedViews: ["Location1": embeddedView], config: nil) { event in if event is RoktEvent.PlacementReady { // Placement is ready } } ``` -------------------------------- ### Set mParticle API Credentials for Recording Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/IntegrationTests/README.md Set environment variables for mParticle API key and secret. These are required only when recording new API interactions. ```bash export MPARTICLE_API_KEY="your-api-key" export MPARTICLE_API_SECRET="your-api-secret" ``` -------------------------------- ### Add OneTrust Kit via CocoaPods Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/onetrust/onetrust/README.md Include the mParticle-OneTrust pod and pin the OneTrust SDK to the version specified in your OneTrust configuration. ```ruby pod 'mParticle-OneTrust', '~> 9.0' pod 'OTPublishersHeadlessSDK', '202502.1.0' # Use the version from your OneTrust UI ``` -------------------------------- ### Multi-platform Podfile Configuration Source: https://github.com/mparticle/mparticle-apple-sdk/wiki/Multi-platform-Configuration Use this configuration in your Podfile when targeting both iOS and tvOS from the same Xcode project. Remember to replace placeholder names with your actual project and target names. ```ruby source 'https://github.com/CocoaPods/Specs.git' inhibit_all_warnings! # Replace with the name of your Xcode project name or a name of your choice abstract_target '' do use_frameworks! pod 'mParticle-Apple-SDK', '~> 6' # Replace with the name of the iOS target in your Xcode project target '' do platform :ios, '8.0' end # Replace with the name of the tvOS target in your Xcode project target '' do platform :tvos, '9.0' end end ``` -------------------------------- ### Edit Tuist Project Configuration Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/IntegrationTests/README.md Open a temporary Xcode project to edit the Tuist manifest files, typically Project.swift. ```bash tuist edit ``` -------------------------------- ### Verify API Key Regex Replacement Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/IntegrationTests/README.md Use 'grep' to confirm that API keys in the mapping file have been successfully replaced with the regex pattern 'us1-[a-f0-9]+'. ```bash grep "us1-\[a-f0-9\]+" wiremock-recordings/mappings/mapping-v1-identify.json ``` -------------------------------- ### Register for CocoaPods Trunk Session Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/RELEASE.md Use this command to register a new session for CocoaPods trunk. You will need to confirm via an email link. ```bash pod trunk register developers@mparticle.com 'mParticle Developers' --description='CI release' ``` -------------------------------- ### Update Podfile for mParticle Kit Extensions Source: https://github.com/mparticle/mparticle-apple-sdk/wiki/Migration-Guide Migrate kit pod declarations to their new, separate pod names for version 6. ```ruby pod 'mParticle-Apple-SDK', '~> 5', :subspecs => ['Appboy'] or pod 'mParticle-Apple-SDK/Appboy', '~> 5' ``` ```ruby target '' do pod 'mParticle-Appboy', '~> 6' end ``` -------------------------------- ### Add Singular Kit via CocoaPods Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/singular/singular-12/README.md Add this dependency to your app's Podfile to include the Singular kit. ```ruby pod 'mParticle-Singular', '~> 9.0' ``` -------------------------------- ### Add mParticle SDK as Git Submodule Source: https://github.com/mparticle/mparticle-apple-sdk/wiki/Manual-installation-instructions Use this command to add the mParticle Apple SDK as a submodule to your project's Git repository. ```bash git submodule add https://github.com/mParticle/mparticle-apple-sdk ``` -------------------------------- ### Register Payment Extension for Shoppable Ads (Objective-C) Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/rokt/rokt/README.md Objective-C equivalent for registering a payment extension, necessary for enabling in-app purchases through Rokt Shoppable Ads. ```objective-c [[MParticle sharedInstance].rokt registerPaymentExtension:stripeExtension]; ``` -------------------------------- ### Check Running Docker Containers Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/IntegrationTests/README.md Use 'docker ps' to list all currently running Docker containers. This helps identify potential conflicts if WireMock ports are already in use. ```bash docker ps ``` -------------------------------- ### Handle Rokt URL Callbacks in Objective-C Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/MIGRATING.md Implement this in your AppDelegate to handle redirect-based payment flows by forwarding the incoming URL to the Rokt SDK. Returns YES if the URL was handled. ```objective-c - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { if ([[MParticle sharedInstance].rokt handleURLCallback:url]) { return YES; } return NO; } ``` -------------------------------- ### Handle ATT Prompt Response and Provide IDFA Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/MIGRATING.md Map the ATTrackingManager authorization status to mParticle's MPATTAuthorizationStatus and provide the IDFA to the mParticle Identity API when authorized. ```swift ATTrackingManager.requestTrackingAuthorization { status in switch status { case .authorized: MParticle.sharedInstance().setATTStatus((MPATTAuthorizationStatus)status, withTimestampMillis: nil) // Now that we are authorized we can get the IDFA, supply to mParticle Identity API as needed var identityRequest = MPIdentityApiRequest.withEmptyUser() identityRequest.setIdentity(ASIdentifierManager.shared().advertisingIdentifier.uuidString, identityType: MPIdentity.iosAdvertiserId) MParticle.sharedInstance().identity.modify(identityRequest, completion: identityCallback) case .denied: MParticle.sharedInstance().setATTStatus((MPATTAuthorizationStatus)status, withTimestampMillis: nil) case .notDetermined: MParticle.sharedInstance().setATTStatus((MPATTAuthorizationStatus)status, withTimestampMillis: nil) case .restricted: MParticle.sharedInstance().setATTStatus((MPATTAuthorizationStatus)status, withTimestampMillis: nil) @unknown default: MParticle.sharedInstance().setATTStatus((MPATTAuthorizationStatus)status, withTimestampMillis: nil) } } ``` -------------------------------- ### Add Apptimize Kit Dependency via Swift Package Manager Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/apptimize/apptimize-3/README.md Use this dependency in Xcode or your Package.swift file to integrate the Apptimize kit. ```swift .package( url: "https://github.com/mparticle-integrations/mparticle-apple-integration-apptimize-3", .upToNextMajor(from: "9.0.0") ) ``` -------------------------------- ### Add Adobe Kit Dependency (CocoaPods) Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/adobe/adobe-5/README.md Add the mParticle-Adobe-5 kit dependency to your app's Podfile when using CocoaPods. ```ruby pod 'mParticle-Adobe-5', '~> 9.0' ``` -------------------------------- ### Add RoktSDKPlus via CocoaPods Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/rokt-sdk-plus/rokt-sdk-plus-ios/README.md Include the RoktSDKPlus pod in your Podfile, matching the version to the desired release. Ensure your deployment target and Swift version align with the upstream podspecs. ```ruby pod 'RoktSDKPlus', '~> 9.1' ``` -------------------------------- ### Add Singular Kit via Swift Package Manager Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/singular/singular-12/README.md Use this dependency URL to add the Singular kit package to your Xcode project or Package.swift file. ```swift .package( url: "https://github.com/mparticle-integrations/mparticle-apple-integration-singular-12", .upToNextMajor(from: "9.0.0") ) ``` -------------------------------- ### Import mParticle SDK in Swift Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/SwiftExample/README.md This is the standard import statement for the mParticle Apple SDK in Swift projects, regardless of whether SPM or XCFramework is used. ```swift import mParticle_Apple_SDK ``` -------------------------------- ### Check Port Usage Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/IntegrationTests/README.md Use 'lsof -i :' to identify which processes are using a specific network port. This is crucial for troubleshooting 'port already in use' errors. ```bash lsof -i :443 ``` ```bash lsof -i :8080 ``` -------------------------------- ### Verify Braze Integration in Xcode Console Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/braze/braze-14/README.md After rebuilding and launching your app, check the Xcode console for confirmation that the Braze kit is included. This requires the mParticle log level to be set to Debug or higher. ```bash Included kits: { Braze } ``` -------------------------------- ### Add Core SDK with CocoaPods Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/README.md Specify the mParticle-Apple-SDK in your Podfile to integrate the core SDK using CocoaPods. Ensure you use the correct version specifier. ```ruby target '' do pod 'mParticle-Apple-SDK', '~> 9' end ``` -------------------------------- ### Add Rokt Kit Dependency via CocoaPods Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/rokt/rokt/README.md Include the mParticle-Rokt kit as a dependency in your application's Podfile for use with CocoaPods. ```ruby pod 'mParticle-Rokt', '~> 9.0' ``` -------------------------------- ### Set User ID Preference Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/iterable/iterable-6/README.md Configure the kit to prefer using a user ID for identification instead of the default email identification. ```swift MPKitIterable.setPrefersUserId(true) ``` -------------------------------- ### Add Sanitized Files to Git Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/IntegrationTests/README.md Stage the sanitized mapping and response body files using 'git add' before committing them to version control. ```bash git add wiremock-recordings/mappings/mapping-identify.json ``` ```bash git add wiremock-recordings/__files/body-identify.json ``` -------------------------------- ### Select Shoppable Ads Source: https://github.com/mparticle/mparticle-apple-sdk/blob/main/Kits/rokt/rokt/README.md Displays a Rokt Shoppable Ads placement, enabling in-app purchases. It supports payment extensions and provides a callback for event handling. ```APIDOC ## Select Shoppable Ads ### Description Displays a Rokt Shoppable Ads placement, facilitating in-app purchases. This method automatically forwards the `stripePublishableKey` configured in the mParticle dashboard and supports registered payment extensions. A callback is provided to handle placement events. ### Method Signature (Swift) ```swift MParticle.sharedInstance().rokt.selectShoppableAds("ShopView", attributes: ["email": "user@example.com"], config: nil) { event in if event is RoktEvent.PlacementReady { // Placement is ready } } ``` ### Method Signature (Objective-C) ```objective-c [[MParticle sharedInstance].rokt selectShoppableAds:@"ShopView" attributes:@{@"email": @"user@example.com"} config:nil onEvent:^(RoktEvent * _Nonnull event) { if ([event isKindOfClass:[RoktPlacementReady class]]) { // Placement is ready } }]; ``` ### Parameters - **placementName** (String) - The name of the Shoppable Ads placement to display. - **attributes** (Dictionary) - Custom attributes to pass with the placement request. - **config** (RoktConfig?) - Optional configuration for the Shoppable Ads placement. - **onEvent** (Callback) - A closure that is called when a Rokt event occurs, such as `RoktPlacementReady`. ``` -------------------------------- ### Update Podfile for mParticle SDK v6 Source: https://github.com/mparticle/mparticle-apple-sdk/wiki/Migration-Guide Replace older mParticle pod declarations with the new mParticle-Apple-SDK for version 6. ```ruby pod 'mParticle', '~> 4' or pod 'mParticle-iOS-SDK', '~> 5' or pod 'mParticle-Apple-SDK', '~> 5' ``` ```ruby target '' do pod 'mParticle-Apple-SDK', '~> 6' end ```