I've been trying since morning creating a cocoa touch farmework to put my self containing widget inside it, and to allow any app I'm working on to use it in the future.
I've managed to build the project and export .framework file, but all the assets are not showing now. all my Images are inside assets catalog.
And they seem to be exported since the .framework file has (assets.car) file inside it.
I'm currently accessing them using
UIImage* icon = [UIImage imageNamed:@"iconName"];
But it always returns null, Any ideas ?
An asset catalog is a type of file used to organize and manage different assets and image resolutions used by your app's user interface.
Cocoa Touch Static Library. A. A static library is a collection of compiled source files which is then linked directly into an app's binary. That is, it becomes a part of your app's binary.
Cocoa and Cocoa Touch are the application development environments for OS X and iOS, respectively. Both Cocoa and Cocoa Touch include the Objective-C runtime and two core frameworks: Cocoa, which includes the Foundation and AppKit frameworks, is used for developing applications that run on OS X.
You can supply the framework bundle when creating an image. In Swift 2:
class func getMyImage() -> UIImage? {
let bundle = NSBundle(forClass: self)
return UIImage(named: "YourImageName", inBundle: bundle, compatibleWithTraitCollection: nil)
}
Swift 3:
class func getMyImage() -> UIImage? {
let bundle = Bundle(for: type(of: self))
return UIImage(named: "YourImageName", in: bundle, compatibleWith: nil)
}
Here is a demo project containing a framework with an image and an app that uses it.
https://github.com/marketplacer/AssetFrameworkDemo
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