Total rebrand across KMM project: - Kotlin package: com.example.casera -> com.tt.honeyDue (dirs + declarations) - Gradle: rootProject.name, namespace, applicationId - Android: manifest, strings.xml (all languages), widget resources - iOS: pbxproj bundle IDs, Info.plist, entitlements, xcconfig - iOS directories: Casera/ -> HoneyDue/, CaseraTests/ -> HoneyDueTests/, etc. - Swift source: all class/struct/enum renames - Deep links: casera:// -> honeydue://, .casera -> .honeydue - App icons replaced with honeyDue honeycomb icon - Domains: casera.treytartt.com -> honeyDue.treytartt.com - Bundle IDs: com.tt.casera -> com.tt.honeyDue - Database table names preserved Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
184 lines
4.6 KiB
Markdown
184 lines
4.6 KiB
Markdown
# Fix: Test Target Configuration
|
|
|
|
## Problem
|
|
|
|
When compiling tests, you're seeing:
|
|
```
|
|
@testable import iosApp
|
|
No such module 'iosApp'
|
|
```
|
|
|
|
This means the test target (`HoneyDueTests`) is not properly configured to access the main app target (`iosApp`).
|
|
|
|
## Solution: Configure Test Target in Xcode
|
|
|
|
### Step 1: Open Xcode Project
|
|
|
|
```bash
|
|
cd /Users/treyt/Desktop/code/HoneyDue/HoneyDueKMM/iosApp
|
|
open iosApp.xcodeproj
|
|
```
|
|
|
|
### Step 2: Add Target Dependency
|
|
|
|
1. **Select the project** in the Project Navigator (top item, blue icon)
|
|
2. **Select `HoneyDueTests` target** in the targets list (middle column)
|
|
3. **Go to "Build Phases" tab** (top of editor)
|
|
4. **Expand "Dependencies" section**
|
|
5. **Click the "+" button** under Dependencies
|
|
6. **Select `iosApp`** from the list
|
|
7. **Click "Add"**
|
|
|
|
### Step 3: Configure Test Host
|
|
|
|
1. Still in **`HoneyDueTests` target** → **Build Settings** tab
|
|
2. **Search for "Test Host"**
|
|
3. Set **Test Host** to:
|
|
```
|
|
$(BUILT_PRODUCTS_DIR)/iosApp.app/iosApp
|
|
```
|
|
4. **Search for "Bundle Loader"**
|
|
5. Set **Bundle Loader** to:
|
|
```
|
|
$(TEST_HOST)
|
|
```
|
|
|
|
### Step 4: Enable Testability
|
|
|
|
1. **Select `iosApp` target** (main app)
|
|
2. Go to **Build Settings** tab
|
|
3. **Search for "Enable Testability"**
|
|
4. Set **Enable Testability** to **YES** for **Debug** configuration
|
|
- (Leave it NO for Release)
|
|
|
|
### Step 5: Verify Module Name
|
|
|
|
1. **Select `iosApp` target**
|
|
2. Go to **Build Settings** tab
|
|
3. **Search for "Product Module Name"**
|
|
4. Verify it says **`iosApp`**
|
|
- If it's different (e.g., "HoneyDue"), you need to update your imports
|
|
|
|
### Step 6: Clean and Build
|
|
|
|
1. **Product** → **Clean Build Folder** (or press `⌘ + Shift + K`)
|
|
2. **Product** → **Build For** → **Testing** (or press `⌘ + Shift + U`)
|
|
|
|
### Step 7: Verify Fix
|
|
|
|
Open any test file (e.g., `ContractorViewModelTests.swift`) and verify the import works:
|
|
|
|
```swift
|
|
@testable import iosApp // Should no longer show error
|
|
```
|
|
|
|
---
|
|
|
|
## Alternative: Command Line Fix (Advanced)
|
|
|
|
If you prefer command-line configuration, you can use `xcodebuild` with PlistBuddy, but the Xcode GUI method above is safer and recommended.
|
|
|
|
---
|
|
|
|
## Visual Guide
|
|
|
|
### What It Should Look Like:
|
|
|
|
**HoneyDueTests Target → Build Phases → Dependencies:**
|
|
```
|
|
✅ iosApp (target)
|
|
```
|
|
|
|
**HoneyDueTests Target → Build Settings:**
|
|
```
|
|
Test Host: $(BUILT_PRODUCTS_DIR)/iosApp.app/iosApp
|
|
Bundle Loader: $(TEST_HOST)
|
|
```
|
|
|
|
**iosApp Target → Build Settings:**
|
|
```
|
|
Enable Testability: Yes (Debug only)
|
|
Product Module Name: iosApp
|
|
```
|
|
|
|
---
|
|
|
|
## Common Issues & Solutions
|
|
|
|
### Issue 1: Still getting "No such module"
|
|
**Solution:**
|
|
- Clean build folder (`⌘ + Shift + K`)
|
|
- Delete derived data:
|
|
```bash
|
|
rm -rf ~/Library/Developer/Xcode/DerivedData/iosApp-*
|
|
```
|
|
- Restart Xcode
|
|
- Build again
|
|
|
|
### Issue 2: Module name is different
|
|
**Solution:**
|
|
- Check what the actual module name is:
|
|
- Select `iosApp` target → Build Settings → Product Module Name
|
|
- Update all test imports to match:
|
|
```swift
|
|
@testable import <ActualModuleName>
|
|
```
|
|
|
|
### Issue 3: "Target is not an application"
|
|
**Solution:**
|
|
- Make sure you selected the **main app target** (`iosApp`), not the extension target
|
|
- The Test Host should point to the `.app` bundle
|
|
|
|
### Issue 4: Xcode can't find the app
|
|
**Solution:**
|
|
- Build the main app first: `⌘ + B`
|
|
- Then build tests: `⌘ + Shift + U`
|
|
|
|
---
|
|
|
|
## Quick Verification Checklist
|
|
|
|
After making changes, verify:
|
|
|
|
- [ ] `HoneyDueTests` target has `iosApp` in Dependencies
|
|
- [ ] Test Host is set to `$(BUILT_PRODUCTS_DIR)/iosApp.app/iosApp`
|
|
- [ ] Bundle Loader is set to `$(TEST_HOST)`
|
|
- [ ] `iosApp` target has "Enable Testability" = YES (Debug)
|
|
- [ ] Product Module Name matches your import statement
|
|
- [ ] Project builds successfully (`⌘ + B`)
|
|
- [ ] Tests build successfully (`⌘ + Shift + U`)
|
|
- [ ] No import errors in test files
|
|
|
|
---
|
|
|
|
## Why This Happens
|
|
|
|
The test target needs explicit configuration to:
|
|
1. **Know which app to test** (Target Dependency)
|
|
2. **Where to find the app binary** (Test Host)
|
|
3. **Access internal/private code** (Enable Testability + @testable import)
|
|
|
|
Without these settings, the compiler doesn't know that `iosApp` module exists.
|
|
|
|
---
|
|
|
|
## After Fixing
|
|
|
|
Once configured, your tests will:
|
|
- ✅ Import the main app module successfully
|
|
- ✅ Access internal classes and methods with `@testable import`
|
|
- ✅ Run against the actual app binary
|
|
- ✅ Have access to all app code for testing
|
|
|
|
---
|
|
|
|
**Estimated Time:** 2-3 minutes
|
|
**Difficulty:** Easy (GUI-based)
|
|
**Risk:** Low (non-destructive changes)
|
|
|
|
---
|
|
|
|
**Last Updated:** November 18, 2025
|
|
**Issue:** Test target not configured for app module access
|
|
**Resolution:** Add target dependency and configure test host in Xcode
|