A Bundle (or NSBundle with Objective-C) is just a collection of resources. When you create an iOS application you start out with a main bundle (the contents of the .app file). When you create a framework Xcode stores the resources for that framework in a separate bundle (the file AmazingFramework.framework in this case).
To get the main bundle for an application:
// Swift
let mainBundle = Bundle.main
// Objective-C
NSBundle *mainBundle = [NSBundle mainBundle];
You can get the bundle that contains a class using init(for aClass: AnyClass). For the framework bundle that contains our AmazingView:
let amazingBundle = Bundle(for: AmazingView.self)
references:
https://useyourloaf.com/blog/loading-resources-from-a-framework/
To get the main bundle for an application:
// Swift
let mainBundle = Bundle.main
// Objective-C
NSBundle *mainBundle = [NSBundle mainBundle];
You can get the bundle that contains a class using init(for aClass: AnyClass). For the framework bundle that contains our AmazingView:
let amazingBundle = Bundle(for: AmazingView.self)
references:
https://useyourloaf.com/blog/loading-resources-from-a-framework/
No comments:
Post a Comment