🤖 AI Agent Instructions
This is the Iterable Swift SDK for iOS/macOS integration. The SDK provides:
- Push notification handling
- In-app messaging
- Event tracking
- User management
- Unknown user tracking
- Core SDK:
swift-sdk/- Main SDK implementation - Sample Apps:
sample-apps/- Example integrations - Tests:
tests/- Unit tests, UI tests, and integration tests - Notification Extension:
notification-extension/- Rich push support
./agent_build.sh- Validates compilation on iOS Simulator
- Shows build errors with context
- Requires macOS with Xcode
./agent_test.sh --list# Run all tests
./agent_test.sh
# Run specific test suite
./agent_test.sh IterableApiCriteriaFetchTests
# Run specific unit test (dot notation - recommended)
./agent_test.sh "IterableApiCriteriaFetchTests.testForegroundCriteriaFetchWhenConditionsMet"
# Run any specific test with path
./agent_test.sh "unit-tests/IterableApiCriteriaFetchTests/testForegroundCriteriaFetchWhenConditionsMet"- Executes on iOS Simulator with accurate pass/fail reporting
- Returns exit code 0 for success, 1 for failures
- Shows detailed test counts and failure information
--listshows all test suites with test counts- Requires password for xcpretty installation (first run)
swift-sdk/
├── swift-sdk/ # Main SDK source
│ ├── Core/ # Public APIs and models
│ ├── Internal/ # Internal implementation
│ ├── SDK/ # Main SDK entry points
│ └── ui-components/ # SwiftUI/UIKit components
├── tests/ # Test suites
│ ├── unit-tests/ # Unit tests
│ ├── ui-tests/ # UI automation tests
│ └── endpoint-tests/ # API endpoint tests
├── sample-apps/ # Example applications
└── notification-extension/ # Push notification extension
- IterableAPI: Main SDK interface
- IterableConfig: Configuration management
- InternalIterableAPI: Core implementation
- UnknownUserManager: Unknown user tracking
- LocalStorage: Data persistence
- Build first:
./agent_build.sh - Implement in
swift-sdk/Internal/orswift-sdk/SDK/ - Add tests in
tests/unit-tests/ - Verify:
./agent_test.sh(all tests) or./agent_test.sh YourTestSuite(specific suite)
- Build script shows compilation errors with file paths
- Check Xcode project references in
swift-sdk.xcodeproj/project.pbxproj - Verify file renames are reflected in project file
- Test script shows specific failures with line numbers and detailed error messages
- Run failing tests individually:
./agent_test.sh "TestSuite.testMethod" - Mock classes available in
tests/common/ - Update parameter names when refactoring APIs
- macOS: Required for Xcode builds
- Xcode: Latest stable version
- Ruby: For xcpretty (auto-installed)
- iOS Simulator: For testing
- Run
./agent_build.shto verify project builds - Run
./agent_test.shto check test health (or./agent_test.sh TestSuitefor specific suite) - Make changes to source files
- Re-run both scripts to validate
- Debug failing tests:
./agent_test.sh "TestSuite.testMethod" - Commit when both pass ✅
# Debug specific failing tests
./agent_test.sh "IterableApiCriteriaFetchTests.testForegroundCriteriaFetchWhenConditionsMet"
# Run a problematic test suite
./agent_test.sh ValidateCustomEventUserUpdateAPITest
# Check auth-related tests
./agent_test.sh AuthTestsIMPORTANT: When you discover something useful while working on this codebase, update this README to help future AI agents. Add learnings to the sections below.
- Auth Logic:
swift-sdk/Internal/AuthManager.swift(main auth manager),swift-sdk/Internal/Auth.swift(auth models) - API Calls:
swift-sdk/Internal/api-client/ApiClient.swift(main client),swift-sdk/Internal/Network/NetworkHelper.swift(networking) - Models:
swift-sdk/Core/Models/(all data structures - CommerceItem, IterableInAppMessage, etc.) - Main Entry:
swift-sdk/SDK/IterableAPI.swift(public-facing methods),swift-sdk/Internal/InternalIterableAPI.swift(core implementation) — note: public API surface lives inIterableAPI.swift, implementation details inApiClient.swift - Request Handling:
swift-sdk/Internal/api-client/Request/(online/offline processors)
Add New API Endpoint:
- Add path constant to
swift-sdk/Core/Constants.swiftinConst.Path - Add method to
ApiClientProtocol.swiftand implement inApiClient.swift - Create request in
swift-sdk/Internal/api-client/Request/RequestCreator.swift - Add to
RequestHandlerProtocol.swiftandRequestHandler.swift
Modify Auth Logic:
- Main logic:
swift-sdk/Internal/AuthManager.swift - Token storage:
swift-sdk/Internal/Utilities/Keychain/IterableKeychain.swift - Auth failures: Handle in
RequestProcessorUtil.swift
Add New Model:
- Create in
swift-sdk/Core/Models/YourModel.swift - Make it
@objcMembers public classfor Objective-C compatibility - Implement
Codableif it needs JSON serialization
"Test X failed" → Check test file in tests/unit-tests/ - often parameter name mismatches after refactoring
"Build failed: file not found" → Update swift-sdk.xcodeproj/project.pbxproj to include new/renamed files
"Auth token issues" → Check AuthManager.swift and ensure JWT format is correct in tests
"Network request fails" → Check endpoint in Constants.swift and request creation in RequestCreator.swift
- Always test builds after refactoring
- Parameter name changes require test file updates
- Project file (
*.pbxproj) may need manual updates for file renames - Sample apps demonstrate SDK usage patterns