| 
 | 1 | +# AGENT README - Iterable Swift SDK  | 
 | 2 | + | 
 | 3 | +## Project Overview  | 
 | 4 | +This is the **Iterable Swift SDK** for iOS/macOS integration. The SDK provides:  | 
 | 5 | +- Push notification handling  | 
 | 6 | +- In-app messaging   | 
 | 7 | +- Event tracking  | 
 | 8 | +- User management  | 
 | 9 | +- Unknown user tracking  | 
 | 10 | + | 
 | 11 | +## Key Architecture  | 
 | 12 | +- **Core SDK**: `swift-sdk/` - Main SDK implementation  | 
 | 13 | +- **Sample Apps**: `sample-apps/` - Example integrations  | 
 | 14 | +- **Tests**: `tests/` - Unit tests, UI tests, and integration tests  | 
 | 15 | +- **Notification Extension**: `notification-extension/` - Rich push support  | 
 | 16 | + | 
 | 17 | +## Development Workflow  | 
 | 18 | + | 
 | 19 | +### 🔨 Building the SDK  | 
 | 20 | +```bash  | 
 | 21 | +./agent_build.sh  | 
 | 22 | +```  | 
 | 23 | +- Validates compilation on iOS Simulator  | 
 | 24 | +- Shows build errors with context  | 
 | 25 | +- Requires macOS with Xcode  | 
 | 26 | + | 
 | 27 | +### Listing All Available Tests  | 
 | 28 | + | 
 | 29 | +# List all available test suites  | 
 | 30 | +```bash  | 
 | 31 | +./agent_test.sh --list  | 
 | 32 | +```  | 
 | 33 | + | 
 | 34 | +### 🧪 Running Tests    | 
 | 35 | +```bash  | 
 | 36 | +# Run all tests  | 
 | 37 | +./agent_test.sh  | 
 | 38 | + | 
 | 39 | +# Run specific test suite  | 
 | 40 | +./agent_test.sh IterableApiCriteriaFetchTests  | 
 | 41 | + | 
 | 42 | +# Run specific unit test (dot notation - recommended)  | 
 | 43 | +./agent_test.sh "IterableApiCriteriaFetchTests.testForegroundCriteriaFetchWhenConditionsMet"  | 
 | 44 | + | 
 | 45 | +# Run any specific test with path   | 
 | 46 | +./agent_test.sh "unit-tests/IterableApiCriteriaFetchTests/testForegroundCriteriaFetchWhenConditionsMet"  | 
 | 47 | +```  | 
 | 48 | +- Executes on iOS Simulator with accurate pass/fail reporting  | 
 | 49 | +- Returns exit code 0 for success, 1 for failures  | 
 | 50 | +- Shows detailed test counts and failure information  | 
 | 51 | +- `--list` shows all test suites with test counts  | 
 | 52 | +- Requires password for xcpretty installation (first run)  | 
 | 53 | + | 
 | 54 | +## Project Structure  | 
 | 55 | +```  | 
 | 56 | +swift-sdk/  | 
 | 57 | +├── swift-sdk/               # Main SDK source  | 
 | 58 | +│   ├── Core/               # Public APIs and models  | 
 | 59 | +│   ├── Internal/           # Internal implementation  | 
 | 60 | +│   ├── SDK/               # Main SDK entry points  | 
 | 61 | +│   └── ui-components/     # SwiftUI/UIKit components  | 
 | 62 | +├── tests/                 # Test suites  | 
 | 63 | +│   ├── unit-tests/        # Unit tests  | 
 | 64 | +│   ├── ui-tests/         # UI automation tests  | 
 | 65 | +│   └── endpoint-tests/   # API endpoint tests  | 
 | 66 | +├── sample-apps/          # Example applications  | 
 | 67 | +└── notification-extension/ # Push notification extension  | 
 | 68 | +```  | 
 | 69 | + | 
 | 70 | +## Key Classes  | 
 | 71 | +- **IterableAPI**: Main SDK interface  | 
 | 72 | +- **IterableConfig**: Configuration management  | 
 | 73 | +- **InternalIterableAPI**: Core implementation  | 
 | 74 | +- **UnknownUserManager**: Unknown user tracking  | 
 | 75 | +- **LocalStorage**: Data persistence  | 
 | 76 | + | 
 | 77 | +## Common Tasks  | 
 | 78 | + | 
 | 79 | +### Adding New Features  | 
 | 80 | +1. Build first: `./agent_build.sh`  | 
 | 81 | +2. Implement in `swift-sdk/Internal/` or `swift-sdk/SDK/`  | 
 | 82 | +3. Add tests in `tests/unit-tests/`  | 
 | 83 | +4. Verify: `./agent_test.sh` (all tests) or `./agent_test.sh YourTestSuite` (specific suite)  | 
 | 84 | + | 
 | 85 | +### Debugging Build Issues  | 
 | 86 | +- Build script shows compilation errors with file paths  | 
 | 87 | +- Check Xcode project references in `swift-sdk.xcodeproj/project.pbxproj`  | 
 | 88 | +- Verify file renames are reflected in project file  | 
 | 89 | + | 
 | 90 | +### Test Failures  | 
 | 91 | +- Test script shows specific failures with line numbers and detailed error messages  | 
 | 92 | +- Run failing tests individually: `./agent_test.sh "TestSuite.testMethod"`  | 
 | 93 | +- Mock classes available in `tests/common/`  | 
 | 94 | +- Update parameter names when refactoring APIs  | 
 | 95 | + | 
 | 96 | +## Requirements  | 
 | 97 | +- **macOS**: Required for Xcode builds  | 
 | 98 | +- **Xcode**: Latest stable version  | 
 | 99 | +- **Ruby**: For xcpretty (auto-installed)  | 
 | 100 | +- **iOS Simulator**: For testing  | 
 | 101 | + | 
 | 102 | +## Quick Start for AI Agents  | 
 | 103 | +1. Run `./agent_build.sh` to verify project builds  | 
 | 104 | +2. Run `./agent_test.sh` to check test health (or `./agent_test.sh TestSuite` for specific suite)  | 
 | 105 | +3. Make changes to source files  | 
 | 106 | +4. Re-run both scripts to validate  | 
 | 107 | +5. Debug failing tests: `./agent_test.sh "TestSuite.testMethod"`  | 
 | 108 | +6. Commit when both pass ✅  | 
 | 109 | + | 
 | 110 | +## Test Filtering Examples  | 
 | 111 | +```bash  | 
 | 112 | +# Debug specific failing tests  | 
 | 113 | +./agent_test.sh "IterableApiCriteriaFetchTests.testForegroundCriteriaFetchWhenConditionsMet"  | 
 | 114 | + | 
 | 115 | +# Run a problematic test suite  | 
 | 116 | +./agent_test.sh ValidateCustomEventUserUpdateAPITest  | 
 | 117 | + | 
 | 118 | +# Check auth-related tests  | 
 | 119 | +./agent_test.sh AuthTests  | 
 | 120 | +```  | 
 | 121 | + | 
 | 122 | +## AI Agent Memory System  | 
 | 123 | + | 
 | 124 | +### 🧠 Update Instructions for AI Agents  | 
 | 125 | +**IMPORTANT**: When you discover something useful while working on this codebase, update this README to help future AI agents. Add learnings to the sections below.  | 
 | 126 | + | 
 | 127 | +### 📍 Code Location Map  | 
 | 128 | +- **Auth Logic**: `swift-sdk/Internal/AuthManager.swift` (main auth manager), `swift-sdk/Internal/Auth.swift` (auth models)  | 
 | 129 | +- **API Calls**: `swift-sdk/Internal/api-client/ApiClient.swift` (main client), `swift-sdk/Internal/Network/NetworkHelper.swift` (networking)  | 
 | 130 | +- **Models**: `swift-sdk/Core/Models/` (all data structures - CommerceItem, IterableInAppMessage, etc.)  | 
 | 131 | +- **Main Entry**: `swift-sdk/SDK/IterableAPI.swift` (public API), `swift-sdk/Internal/InternalIterableAPI.swift` (core implementation)  | 
 | 132 | +- **Request Handling**: `swift-sdk/Internal/api-client/Request/` (online/offline processors)  | 
 | 133 | + | 
 | 134 | +### 🛠️ Common Task Recipes  | 
 | 135 | + | 
 | 136 | +**Add New API Endpoint:**  | 
 | 137 | +1. Add path constant to `swift-sdk/Core/Constants.swift` in `Const.Path`  | 
 | 138 | +2. Add method to `ApiClientProtocol.swift` and implement in `ApiClient.swift`  | 
 | 139 | +3. Create request in `swift-sdk/Internal/api-client/Request/RequestCreator.swift`  | 
 | 140 | +4. Add to `RequestHandlerProtocol.swift` and `RequestHandler.swift`  | 
 | 141 | + | 
 | 142 | +**Modify Auth Logic:**  | 
 | 143 | +- Main logic: `swift-sdk/Internal/AuthManager.swift`  | 
 | 144 | +- Token storage: `swift-sdk/Internal/Utilities/Keychain/IterableKeychain.swift`  | 
 | 145 | +- Auth failures: Handle in `RequestProcessorUtil.swift`  | 
 | 146 | + | 
 | 147 | +**Add New Model:**  | 
 | 148 | +- Create in `swift-sdk/Core/Models/YourModel.swift`  | 
 | 149 | +- Make it `@objcMembers public class` for Objective-C compatibility  | 
 | 150 | +- Implement `Codable` if it needs JSON serialization  | 
 | 151 | + | 
 | 152 | +### 🐛 Common Failure Solutions  | 
 | 153 | + | 
 | 154 | +**"Test X failed"** → Check test file in `tests/unit-tests/` - often parameter name mismatches after refactoring  | 
 | 155 | + | 
 | 156 | +**"Build failed: file not found"** → Update `swift-sdk.xcodeproj/project.pbxproj` to include new/renamed files  | 
 | 157 | + | 
 | 158 | +**"Auth token issues"** → Check `AuthManager.swift` and ensure JWT format is correct in tests  | 
 | 159 | + | 
 | 160 | +**"Network request fails"** → Check endpoint in `Constants.swift` and request creation in `RequestCreator.swift`  | 
 | 161 | + | 
 | 162 | +## Notes  | 
 | 163 | +- Always test builds after refactoring  | 
 | 164 | +- Parameter name changes require test file updates  | 
 | 165 | +- Project file (`*.pbxproj`) may need manual updates for file renames  | 
 | 166 | +- Sample apps demonstrate SDK usage patterns   | 
0 commit comments