I have a CalendarCell.xib and a CalendarCell.swift UIView subclass in my Pod framework. CalendarCell.swift has outlets connected to its view. At runtime I get this error:
Could not load NIB in bundle: 'NSBundle (loaded)' with name 'CalendarCell'
In my podspec file I created a bundle resource:
s.resource_bundles = { 'Resources' => ['MyFramework/**/*.{xib,xcassets}'] }
If I install my Pod I can see the xib file but it crashes and now it seems that the xib file and its swift counterpart are in different bundle.
Any help would be appreciated!
You're right, the xibs are stored in a different bundle. You need to find the path of the xibs bundle and load all the xibs from that bundle, instead of loading them from the main bundle.
To find the path of the bundle, in Swift 3:
let bundle = Bundle(for: YourClass.self)
So, you have to load your UINib
from that bundle:
let nib = UINib(nibName: "YourXibName", bundle: bundle)
and register it to your UITableView
/UICollectionView
, if you need it for this purpose:
self.tableView.register(nib, forCellReuseIdentifier: "cellIdentifier")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With