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>
4.6 KiB
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
cd /Users/treyt/Desktop/code/HoneyDue/HoneyDueKMM/iosApp
open iosApp.xcodeproj
Step 2: Add Target Dependency
- Select the project in the Project Navigator (top item, blue icon)
- Select
HoneyDueTeststarget in the targets list (middle column) - Go to "Build Phases" tab (top of editor)
- Expand "Dependencies" section
- Click the "+" button under Dependencies
- Select
iosAppfrom the list - Click "Add"
Step 3: Configure Test Host
- Still in
HoneyDueTeststarget → Build Settings tab - Search for "Test Host"
- Set Test Host to:
$(BUILT_PRODUCTS_DIR)/iosApp.app/iosApp - Search for "Bundle Loader"
- Set Bundle Loader to:
$(TEST_HOST)
Step 4: Enable Testability
- Select
iosApptarget (main app) - Go to Build Settings tab
- Search for "Enable Testability"
- Set Enable Testability to YES for Debug configuration
- (Leave it NO for Release)
Step 5: Verify Module Name
- Select
iosApptarget - Go to Build Settings tab
- Search for "Product Module Name"
- Verify it says
iosApp- If it's different (e.g., "HoneyDue"), you need to update your imports
Step 6: Clean and Build
- Product → Clean Build Folder (or press
⌘ + Shift + K) - 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:
@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:
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
iosApptarget → Build Settings → Product Module Name
- Select
- Update all test imports to match:
@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
.appbundle
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:
HoneyDueTeststarget hasiosAppin Dependencies- Test Host is set to
$(BUILT_PRODUCTS_DIR)/iosApp.app/iosApp - Bundle Loader is set to
$(TEST_HOST) iosApptarget 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:
- Know which app to test (Target Dependency)
- Where to find the app binary (Test Host)
- 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