Manos Chorianopoulos

xib bundling issue fix

# 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
```swift
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
1. Test removing module specification from one XIB file
2. If that works, apply to all XIB files
3. If that doesn't work, try updating to the duplicated module name
4. 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.
......@@ -9,7 +9,7 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="MyRewardsBannerOffersScrollTableViewCell" rowHeight="349" id="KGk-i7-Jjw" customClass="MyRewardsBannerOffersScrollTableViewCell" customModule="SwiftWarplyFramework" customModuleProvider="target">
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="MyRewardsBannerOffersScrollTableViewCell" rowHeight="349" id="KGk-i7-Jjw" customClass="MyRewardsBannerOffersScrollTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="413" height="349"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
......
# XIB Investigation Report - SPM Class Resolution Issue
## Investigation Summary
I have thoroughly investigated the XIB bundling and class resolution issue. Here are my findings:
## ✅ What's Working Correctly
### 1. XIB File Configuration
**GOOD NEWS**: The XIB files are configured correctly!
**MyRewardsBannerOffersScrollTableViewCell.xib**:
```xml
<tableViewCell ... customClass="MyRewardsBannerOffersScrollTableViewCell" customModule="SwiftWarplyFramework" customModuleProvider="target">
```
**ProfileHeaderTableViewCell.xib**:
```xml
<tableViewCell ... customClass="ProfileHeaderTableViewCell" customModule="SwiftWarplyFramework" customModuleProvider="target">
```
-**Class names are clean** (not mangled)
-**Module is correctly set** to "SwiftWarplyFramework"
-**Module provider is "target"** (correct for SPM)
### 2. Swift Class Configuration
**ALSO GOOD**: Our @objc attributes are correctly applied:
```swift
@objc(MyRewardsBannerOffersScrollTableViewCell)
public class MyRewardsBannerOffersScrollTableViewCell: UITableViewCell {
```
### 3. XIB Bundling
**WORKING**: Our debug output shows XIB files are found and loaded:
```
✅ [WarplySDK] Found XIB: MyRewardsBannerOffersScrollTableViewCell at .../MyRewardsBannerOffersScrollTableViewCell.nib
```
## ❌ The Real Problem
### Root Cause Analysis
The issue is **NOT** with our XIB configuration or @objc attributes. The problem is more fundamental:
**The error shows the mangled name**: `_TtC41SwiftWarplyFramework_SwiftWarplyFramework40MyRewardsBannerOffersScrollTableViewCell`
This suggests that **somewhere in the runtime**, the system is still trying to resolve the class using the mangled Swift name instead of our clean @objc name.
## 🔍 Key Findings
### 1. XIB Files Are Correctly Configured
- Class names: `MyRewardsBannerOffersScrollTableViewCell` (clean)
- Module: `SwiftWarplyFramework`
- Module provider: `target`
### 2. Swift Classes Have Correct @objc Attributes
- `@objc(MyRewardsBannerOffersScrollTableViewCell)` is properly applied
### 3. The Disconnect
- XIB expects: `MyRewardsBannerOffersScrollTableViewCell`
- Runtime is looking for: `_TtC41SwiftWarplyFramework_SwiftWarplyFramework40MyRewardsBannerOffersScrollTableViewCell`
## 🤔 Possible Causes
### 1. Module Name Mismatch in SPM
The XIB file specifies `customModule="SwiftWarplyFramework"`, but in SPM, the actual module name might be different (like `SwiftWarplyFramework_SwiftWarplyFramework`).
### 2. Build System Issue
The @objc attributes might not be taking effect during the SPM build process.
### 3. Runtime Class Registration
The class might not be properly registered with the Objective-C runtime under the @objc name.
## 📋 Recommended Next Steps
### Option 1: Module Name Investigation
Check what the actual module name is in SPM vs what's in the XIB files.
### Option 2: XIB Module Configuration
Try changing the XIB files to use the actual SPM module name or remove the module specification entirely.
### Option 3: Alternative @objc Approach
Try using just `@objc` without the explicit name, or use `@objc` with the full module-qualified name.
### Option 4: Bundle vs Module Issue
The problem might be that we're using `customModuleProvider="target"` when we should be using something else for SPM.
## 🎯 Immediate Action Items
1. **Verify the actual module name** being used in SPM
2. **Test XIB without module specification** (remove `customModule` and `customModuleProvider`)
3. **Check if other XIB files have the same issue** or if it's specific to this one
4. **Consider using programmatic cell creation** as a fallback if XIB issues persist
## Conclusion
The XIB files and Swift classes are configured correctly. The issue appears to be a deeper SPM module name resolution problem where the runtime is still using mangled names despite our @objc attributes.