I am using Cocoapods pre-release 0.36 to build and deploy a private dynamic framework into an app bundle. I am using the resources attribute to copy xibs, and they show up in the app bundle.
s.subspec 'Views' do |ss|
...
ss.resources = ['All/My/Folders/**/*.{xib,png}']
...
I am trying to load reusable controls from the xibs like this:
NSBundle.mainBundle().loadNibNamed("MyXib", owner:loader, options:nil)
but this is failing as it cannot find the xib in my embedded sub framework. The actual xib (nib) paths follow the pattern:'
./Frameworks/MyPrivateFramework.framework/MyXib.nib
My question is, is there a simple, code agnostic way of loading the xib that will work when packaged in an iOS 8 framework - or do I have to explicitly hardcode in the above path? The above loading code worked until I think the dynamic framework change.
Thanks
From this post here:
http://artsy.github.io/blog/2015/01/04/cocoapods-and-frameworks/
I arrived at the agnostic solution of getting the framework bundle from a class within, ie:
NSBundle(forClass: ClassInFramework.self)
and then loading the xib from that:
NSBundle(forClass: ClassInFramework.self)
.loadNibNamed("ClassInFramework", owner:loader, options:nil)
and that worked.
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