I am trying to create a UIImage from an asset (icon). My code is approximately:
public class MyModule: NSObject { } let classBundle = NSBundle(forClass: MyModule.self) let bundleURL = classBundle.URLForResource("WeatherUI", withExtension: "bundle") let bundle = NSBundle(URL: bundleURL!) print(bundle) // "foo" corresponds to foo.imageset let image = UIImage(named: "foo", inBundle: bundle, compatibleWithTraitCollection: nil)
image always zero. Package listing:
Optional(NSBundle </Users/user/Library/Developer/Xcode/DerivedData/MyModule-dxpuooiqxaovvrbdrptwxiypbvwh/Build/Products/Debug-iphonesimulator/MyModule.framework/MyModule.bundle> (not yet loaded))
The path is valid (I ls ed it). Also pay attention to not yet loaded . I tried to reset the simulator. I also tried bundle?.load() , but this results in:
2016-07-15 15:55:24.051 MyModule_Example[25549:306130] Cannot find executable for CFBundle 0x7fc204880770 </Users/user/Library/Developer/Xcode/DerivedData/MyModule-dxpuooiqxaovvrbdrptwxiypbvwh/Build/Products/Debug-iphonesimulator/MyModule.framework/MyModule.bundle> (not loaded)
Pay attention to not loaded . I also tried to remove DerivedData .
Any ideas?
source share