OBJC_ATTRIBUTES_FIX_SUMMARY.md 3.78 KB

@objc Attributes Fix for SPM Class Resolution

Problem

XIB files in SPM couldn't find Swift classes due to name mangling differences between CocoaPods and SPM, causing:

Unknown class _TtC41SwiftWarplyFramework_SwiftWarplyFramework40MyRewardsBannerOffersScrollTableViewCell in Interface Builder file.
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UITableViewCell 0x105f2d060> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key collectionView.'

Solution

Added explicit @objc(ClassName) attributes to all cell classes to provide stable, predictable class names for XIB file instantiation.

Classes Updated

Table View Cells:

  1. MyRewardsBannerOffersScrollTableViewCell - @objc(MyRewardsBannerOffersScrollTableViewCell)
  2. MyRewardsOffersScrollTableViewCell - @objc(MyRewardsOffersScrollTableViewCell)
  3. ProfileCouponFiltersTableViewCell - @objc(ProfileCouponFiltersTableViewCell)
  4. ProfileHeaderTableViewCell - @objc(ProfileHeaderTableViewCell)
  5. ProfileQuestionnaireTableViewCell - @objc(ProfileQuestionnaireTableViewCell)
  6. ProfileCouponTableViewCell - @objc(ProfileCouponTableViewCell)

Collection View Cells:

  1. MyRewardsOfferCollectionViewCell - @objc(MyRewardsOfferCollectionViewCell)
  2. MyRewardsBannerOfferCollectionViewCell - @objc(MyRewardsBannerOfferCollectionViewCell)
  3. ProfileFilterCollectionViewCell - @objc(ProfileFilterCollectionViewCell)

What This Fix Does

Before:

  • Swift name mangling in SPM: _TtC41SwiftWarplyFramework_SwiftWarplyFramework40MyRewardsBannerOffersScrollTableViewCell
  • XIB files couldn't find the class
  • Fell back to generic UITableViewCell
  • Crashed when trying to connect collectionView outlet

After:

  • Explicit Objective-C name: MyRewardsBannerOffersScrollTableViewCell
  • XIB files can reliably find the class
  • Proper class instantiation
  • All outlets connect correctly

Benefits

  1. Stable Class Names - XIB files always find the correct class regardless of Swift name mangling
  2. SPM Compatibility - Works consistently in SPM environments
  3. CocoaPods Compatibility - Maintains backward compatibility
  4. No Swift Regression - All Swift features and improvements remain intact
  5. Industry Standard - Common practice for Swift frameworks using XIB files

Testing

After this fix, you should see:

  • No more "Unknown class" errors
  • Successful XIB instantiation
  • Proper outlet connections
  • No crashes related to key-value coding compliance

Files Modified

  1. SwiftWarplyFramework/SwiftWarplyFramework/cells/MyRewardsBannerOffersScrollTableViewCell/MyRewardsBannerOffersScrollTableViewCell.swift
  2. SwiftWarplyFramework/SwiftWarplyFramework/cells/MyRewardsOffersScrollTableViewCell/MyRewardsOffersScrollTableViewCell.swift
  3. SwiftWarplyFramework/SwiftWarplyFramework/cells/ProfileCouponFiltersTableViewCell/ProfileCouponFiltersTableViewCell.swift
  4. SwiftWarplyFramework/SwiftWarplyFramework/cells/ProfileHeaderTableViewCell/ProfileHeaderTableViewCell.swift
  5. SwiftWarplyFramework/SwiftWarplyFramework/cells/ProfileQuestionnaireTableViewCell/ProfileQuestionnaireTableViewCell.swift
  6. SwiftWarplyFramework/SwiftWarplyFramework/cells/ProfileCouponTableViewCell/ProfileCouponTableViewCell.swift
  7. SwiftWarplyFramework/SwiftWarplyFramework/cells/MyRewardsOfferCollectionViewCell/MyRewardsOfferCollectionViewCell.swift
  8. SwiftWarplyFramework/SwiftWarplyFramework/cells/MyRewardsBannerOfferCollectionViewCell/MyRewardsBannerOfferCollectionViewCell.swift
  9. SwiftWarplyFramework/SwiftWarplyFramework/cells/ProfileFilterCollectionViewCell/ProfileFilterCollectionViewCell.swift

This fix should resolve the XIB class resolution issue and eliminate the NSUnknownKeyException crashes in SPM environments.