Module Name Analysis - SPM vs XIB Configuration
The Configuration Mystery Solved
After examining the Package.swift file, I can now explain exactly what's happening with the module names.
Package.swift Configuration
let package = Package(
name: "SwiftWarplyFramework", // Package name
products: [
.library(
name: "SwiftWarplyFramework", // Library name
targets: ["SwiftWarplyFramework"] // Target name
),
],
targets: [
.target(
name: "SwiftWarplyFramework", // Target name
path: "SwiftWarplyFramework/SwiftWarplyFramework", // Path to source
// ... resources and dependencies
),
]
)
The Root Cause
The issue is NOT with our Package.swift configuration. Everything is correctly named SwiftWarplyFramework
. The problem is elsewhere.
Evidence Analysis
1. Package Configuration ✅
-
Package name:
SwiftWarplyFramework
-
Library name:
SwiftWarplyFramework
-
Target name:
SwiftWarplyFramework
- All consistent and correct
2. XIB Configuration ✅
-
customModule:
SwiftWarplyFramework
- Matches the package/target name perfectly
3. Runtime Behavior ❌
-
Error shows:
_TtC41SwiftWarplyFramework_SwiftWarplyFramework40MyRewardsBannerOffersScrollTableViewCell
-
Bundle path:
SwiftWarplyFramework_SwiftWarplyFramework.bundle
The Real Issue
The mangled name SwiftWarplyFramework_SwiftWarplyFramework
suggests that SPM is somehow duplicating the module name during the build process, even though our configuration is correct.
Possible Causes
1. SPM Build System Bug
SPM might be generating incorrect module names due to the directory structure:
SwiftWarplyFramework/ # Root directory
└── SwiftWarplyFramework/ # Target directory
└── SwiftWarplyFramework/ # Source files
2. Client Integration Issue
The way the client app is integrating the SPM package might be causing module name duplication.
3. Xcode/SPM Version Issue
This could be a known issue with certain versions of Xcode or SPM.
Debugging Steps
1. Check Client's Package.resolved
The client's Package.resolved
file might show how SPM is resolving the module name.
2. Check Build Logs
The actual build logs would show what module name SPM is using during compilation.
3. Test with Simplified Structure
We could test if flattening the directory structure resolves the issue.
Immediate Solutions to Try
Option 1: Update XIB Module Name
Change XIB files to use SwiftWarplyFramework_SwiftWarplyFramework
as the module name.
Option 2: Remove Module Specification
Remove customModule
and customModuleProvider
from XIB files entirely.
Option 3: Add Explicit Module Name
Add an explicit swiftSettings
to the target to force the module name.
Recommendation
I recommend trying Option 2 first (removing module specification from XIB files) as this is the least invasive and most likely to work across different SPM configurations.
Next Steps
- Test removing module specification from one XIB file
- If that works, apply to all XIB files
- If that doesn't work, try updating to the duplicated module name
- Document the final solution for future reference
The key insight is that our Package.swift is correct, but SPM is somehow generating a different module name than expected during the build process.