Konstantin Petrukhnov
11/19/2019, 4:42 PMlet b1 = Bundle(for: KotlinInt.self).bundlePath
But calling similar code in Kotlin code resolved to main app bundle (same with specific MyClass that inside framework):
val bundle1 = NSBundle.bundleForClass(object_getClass(Int)!!).bundlePath
Calling to get all bundles, successfully resolve all bundles as list:
val bundle7 = NSBundle.allBundles().joinToString { (it as NSBundle).bundlePath }
Is there some better way, than iterate through all bundles and try to find resource in each of it?
(bundle as NSBundle).pathForResource(fileName, null)
svyatoslav.scherbina
11/20/2019, 8:32 AMThis code is not equivalent and not supposed to work as you expect.val bundle1 = NSBundle.bundleForClass(object_getClass(Int)!!).bundlePath
iterate through all bundles and try to find resource in each of itWhat’s wrong with this? Alternatively you could find a bundle by name.
Konstantin Petrukhnov
11/21/2019, 4:12 AMhttps://raw.githubusercontent.com/Ekahau/khtf/master/docs/concept.png▾
svyatoslav.scherbina
11/21/2019, 7:07 AMIterating through all bundles is acceptable workaround, but there is chance, that same filename appear in some other library (e.g. Alamofire), and it will cause some bugs.Not sure if choosing a unique name is a problem. For example, you can include some unique name of your library (e.g. package name) into the resource path (e.g. as a subdirectory name).
Konstantin Petrukhnov
11/21/2019, 8:35 AMmarcinmoskala
11/23/2019, 11:54 PM