Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I load a xib file from my cocoapod?

Tags:

ios

cocoapods

My xib files are in the Assets folder of my Pod like this.

s.resources = 'Pod/Assets'

The xib files show up in my workspace in the Development Pods group of the cocoa pod. I'm trying to access the xib like this.

[[NSBundle mainBundle] loadNibNamed:@"LabeledTextFieldView" owner:self options:nil];

But I get the following crash

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/jeff.wolski/Library/Application Support/iPhone Simulator/7.1/Applications/775EB653-519B-4FCF-8CD9-92311E205598/LT-Components-iOS.app> (loaded)' with name 'LabeledTextFieldView''

Why is the xib file not found in the bundle?

like image 567
Jeff Wolski Avatar asked Aug 21 '14 18:08

Jeff Wolski


People also ask

What is an XIB file?

What are XIB files? From the point of view of the UI designer, XIB files contain the views or windows that you design in Interface Builder – the controls, their layout and properties, and their connections to your code. It is important to understand that on a technical level, XIB files are stored object graphs.

How do I load a controller from XIB Swift?

Once you decided on a type of UI Controller (View, TableView, CollectionView, etc.), go into File > New > File (⌘N) and select Cocoa Touch Class . Click next. Now we are going to select the subclass and give the new UI Element a name. Let's call it RateMe, with the type of UIViewController .


1 Answers

The s.resources folder will not automatically recurse to subdirectories. I had to specify the full relative path to the xib files.

like image 151
Jeff Wolski Avatar answered Oct 09 '22 03:10

Jeff Wolski