Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Framework/mParticle-Apple-SDK.modulemap

This file was deleted.

7 changes: 5 additions & 2 deletions IntegrationTests/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ import ProjectDescription

let project = Project(
name: "IntegrationTests",
packages: [
.package(path: "../")
],
targets: [
.target(
name: "IntegrationTests",
destinations: .iOS,
product: .app,
bundleId: "com.mparticle.IntegrationTests",
deploymentTargets: .iOS("14.0"),
deploymentTargets: .iOS("15.6"),
sources: ["Sources/**"],
dependencies: [
.xcframework(path: "temp_artifacts/mParticle_Apple_SDK.xcframework")
.package(product: "mParticle-Apple-SDK-NoLocation", type: .runtime)
]
)
],
Expand Down
50 changes: 22 additions & 28 deletions IntegrationTests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ tuist generate

This project provides tools for recording mParticle SDK API requests by:

- Building mParticle SDK as an xcframework for iOS Simulator
- Generating a test iOS app using Tuist that links to the built framework
- Using mParticle SDK via source-based distribution (Swift Package Manager)
- Generating a test iOS app using Tuist that links to the SDK package
- Running the app in iOS Simulator
- Recording all API traffic with WireMock for later use in testing

The project builds the SDK into an xcframework stored in `temp_artifacts/` before each test run, ensuring tests always use your latest code changes. The framework is built for iOS Simulator only for faster compilation times during testing.
The project uses the SDK directly from source via Swift Package Manager, ensuring tests always use your latest code changes without requiring a separate build step.

## Available Scripts

Expand All @@ -72,28 +72,23 @@ Records all mParticle SDK API requests using WireMock for later use in integrati

**What it does:**

1. Builds mParticle SDK as xcframework for iOS Simulator
2. Generates Tuist project linked to the built framework
3. Builds the integration test application
4. Finds and resets iOS Simulators
5. Automatically selects available iPhone simulator (iPhone 17/16/15 priority)
6. Starts simulator
7. Installs test application
8. Starts WireMock in recording mode
9. Launches test application
10. Records all API traffic to mapping files
11. Waits for application completion
12. Stops WireMock and shows results
1. Generates Tuist project linked to mParticle SDK via Swift Package Manager (source-based)
2. Builds the integration test application
3. Finds and resets iOS Simulators
4. Automatically selects available iPhone simulator (iPhone 17/16/15 priority)
5. Starts simulator
6. Installs test application
7. Starts WireMock in recording mode
8. Launches test application
9. Records all API traffic to mapping files
10. Waits for application completion
11. Stops WireMock and shows results

**Recorded Files:**

- `wiremock-recordings/mappings/*.json` - API request/response mappings
- `wiremock-recordings/__files/*` - Response body files

**Build Artifacts:**

- `temp_artifacts/mParticle_Apple_SDK.xcframework` - Compiled SDK framework (auto-generated, not committed to git)

### `sanitize_mapping.py` - Remove API Keys and Rename WireMock Mappings

Sanitizes WireMock mapping files by replacing API keys in URLs with regex patterns, removing API keys from filenames, and renaming files based on test name.
Expand Down Expand Up @@ -285,13 +280,12 @@ Use the verification script to run full end-to-end integration tests:

**What the verification script does:**

1. **Rebuilds SDK:** Compiles mParticle SDK as xcframework for iOS Simulator from latest source code
2. **Regenerates project:** Runs Tuist to regenerate project linked to the new xcframework
3. **Resets environment:** Cleans simulators and builds test app
4. **📝 Prepares mappings:** Escapes request body JSON in WireMock mappings for proper matching
5. **Starts WireMock:** Launches WireMock container in verification mode with updated mappings
6. **Runs tests:** Executes test app in simulator
7. **Verifies results:** Checks that all requests matched mappings and all mappings were invoked
8. **Returns exit code:** Exits with code 1 if any verification fails (CI/CD compatible)
1. **Regenerates project:** Runs Tuist to regenerate project linked to mParticle SDK via Swift Package Manager (source-based)
2. **Resets environment:** Cleans simulators and builds test app
3. **📝 Prepares mappings:** Escapes request body JSON in WireMock mappings for proper matching
4. **Starts WireMock:** Launches WireMock container in verification mode with updated mappings
5. **Runs tests:** Executes test app in simulator
6. **Verifies results:** Checks that all requests matched mappings and all mappings were invoked
7. **Returns exit code:** Exits with code 1 if any verification fails (CI/CD compatible)

**Note:** The SDK xcframework is built fresh on each run, stored in `temp_artifacts/mParticle_Apple_SDK.xcframework`. This ensures tests always use your latest code changes.
**Note:** The SDK is used directly from source via Swift Package Manager, ensuring tests always use your latest code changes without requiring a separate build step.
4 changes: 1 addition & 3 deletions IntegrationTests/run_clean_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ MAPPINGS_DIR=${3:-"./wiremock-recordings"}
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/common.sh"

# === Build framework and generate project ===
build_framework

# === Generate project with Tuist (using source-based distribution) ===
echo "🔄 Generating project with Tuist..."
tuist generate --no-open

Expand Down
4 changes: 1 addition & 3 deletions IntegrationTests/run_integration_tests_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ WIREMOCK_JAR="${WIREMOCK_JAR:-../wiremock.jar}"
WIREMOCK_PID_FILE="${SCRIPT_DIR}/wiremock.pid"
WIREMOCK_LOG_FILE="${SCRIPT_DIR}/wiremock.log"

# === Build framework and generate project ===
build_framework

# === Generate project with Tuist (using source-based distribution) ===
echo "🔄 Generating project with Tuist..."
tuist generate --no-open

Expand Down
4 changes: 1 addition & 3 deletions IntegrationTests/run_wiremock_recorder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ if [[ -z ${MPARTICLE_API_KEY} ]] || [[ -z ${MPARTICLE_API_SECRET} ]]; then
exit 1
fi

# === Build framework and generate project ===
build_framework

# === Generate project with Tuist (using source-based distribution) ===
echo "🔄 Generating project with Tuist..."
tuist generate --no-open

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"fi": true,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"fi": false,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"fi": true,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"fi": true,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"fi": true,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"fi": false,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"fi": false,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"fi": false,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"fi": false,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"fi": false,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"fi": false,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"fi": false,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"fi": true,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"fi": false,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"fi": false,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"fi": false,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"fi": false,
"lud": "${json-unit.ignore}",
"arc": "arm64",
"tsv": "150600",
"tsv": "150000",
"apn": "com.mparticle.IntegrationTests",
"env": 1,
"abn": "1",
Expand Down
53 changes: 42 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.3
// swift-tools-version:5.5

import PackageDescription

Expand All @@ -11,12 +11,8 @@ let mParticle_Apple_SDK_NoLocation_Checksum = "c9aeeb511c407604dd31137e5c7141204

let package = Package(
name: "mParticle-Apple-SDK",
platforms: [.iOS(.v9), .tvOS(.v9)],
platforms: [.iOS(.v15), .tvOS(.v15)],
products: [
.library(
name: "mParticle-Apple-SDK",
targets: ["mParticle_Apple_SDK"]
),
.library(
name: "mParticle-Apple-SDK-NoLocation",
targets: ["mParticle_Apple_SDK_NoLocation"]
Expand All @@ -25,13 +21,48 @@ let package = Package(
dependencies: [
],
targets: [
.binaryTarget(
name: "mParticle_Apple_SDK",
url: mParticle_Apple_SDK_URL,
checksum: mParticle_Apple_SDK_Checksum
// Swift-only components
.target(
name: "mParticle_Apple_SDK_Swift",
path: "mParticle-Apple-SDK-Swift/Sources",
),
.binaryTarget(
// Objective-C SDK (NoLocation variant) - source-based distribution
.target(
name: "mParticle_Apple_SDK_NoLocation",
dependencies: ["mParticle_Apple_SDK_Swift"],
path: "mParticle-Apple-SDK",
sources: nil,
resources: [
.process("../PrivacyInfo.xcprivacy")
],
publicHeadersPath: "Include",
cSettings: [
.headerSearchPath("."),
.headerSearchPath("Include"),
.headerSearchPath("Logger"),
.headerSearchPath("Network"),
.headerSearchPath("Identity"),
.headerSearchPath("Event"),
.headerSearchPath("Ecommerce"),
.headerSearchPath("Kits"),
.headerSearchPath("Utils"),
.headerSearchPath("Persistence"),
.headerSearchPath("Consent"),
.headerSearchPath("Custom Modules"),
.headerSearchPath("AppNotifications"),
.headerSearchPath("Data Model"),
.headerSearchPath("Libraries/Reachability")
],
linkerSettings: [
.linkedFramework("Foundation"),
.linkedFramework("UIKit", .when(platforms: [.iOS])),
.linkedFramework("WebKit", .when(platforms: [.iOS])),
.linkedFramework("UserNotifications", .when(platforms: [.iOS]))
]
),
// Binary target (kept for backward compatibility or as alternative)
.binaryTarget(
name: "mParticle_Apple_SDK_NoLocation_Binary",
url: mParticle_Apple_SDK_NoLocation_URL,
checksum: mParticle_Apple_SDK_NoLocation_Checksum
),
Expand Down
Loading
Loading