diff --git a/resources/src/appleMain/kotlin/dev/icerock/moko/resources/desc/StringDesc.kt b/resources/src/appleMain/kotlin/dev/icerock/moko/resources/desc/StringDesc.kt index 73b719701..8f87793cc 100644 --- a/resources/src/appleMain/kotlin/dev/icerock/moko/resources/desc/StringDesc.kt +++ b/resources/src/appleMain/kotlin/dev/icerock/moko/resources/desc/StringDesc.kt @@ -4,7 +4,6 @@ package dev.icerock.moko.resources.desc -import kotlin.native.concurrent.ThreadLocal import platform.Foundation.NSBundle import platform.Foundation.NSLocale import platform.Foundation.NSLocaleCountryCode @@ -13,6 +12,7 @@ import platform.Foundation.NSLocaleVariantCode import platform.Foundation.currentLocale import platform.Foundation.localeIdentifier import platform.Foundation.localeIdentifierFromComponents +import kotlin.native.concurrent.ThreadLocal actual interface StringDesc { fun localized(): String diff --git a/resources/src/appleMain/kotlin/dev/icerock/moko/resources/utils/NSBundleExt.kt b/resources/src/appleMain/kotlin/dev/icerock/moko/resources/utils/NSBundleExt.kt index 4bbad6338..e8e6bda0e 100644 --- a/resources/src/appleMain/kotlin/dev/icerock/moko/resources/utils/NSBundleExt.kt +++ b/resources/src/appleMain/kotlin/dev/icerock/moko/resources/utils/NSBundleExt.kt @@ -11,9 +11,6 @@ import platform.Foundation.NSURL import platform.Foundation.pathExtension fun NSBundle.Companion.loadableBundle(identifier: String): NSBundle { - // try get already loaded bundle - NSBundle.bundleWithIdentifier(identifier)?.let { return it } - val bundlePath: String = NSBundle.mainBundle.bundlePath val enumerator: NSDirectoryEnumerator = requireNotNull(NSFileManager.defaultManager.enumeratorAtPath(bundlePath)) while (true) { @@ -21,15 +18,18 @@ fun NSBundle.Companion.loadableBundle(identifier: String): NSBundle { val url = NSURL(fileURLWithPath = relativePath) if (url.pathExtension == "bundle") { val fullPath = "$bundlePath/$relativePath" - val loadedIdentifier: String? = NSBundle.bundleWithPath(fullPath)?.bundleIdentifier + val foundedBundle: NSBundle? = NSBundle.bundleWithPath(fullPath) + val loadedIdentifier: String? = foundedBundle?.bundleIdentifier + if (isBundleSearchLogEnabled) { println("moko-resources auto-load bundle with identifier $loadedIdentifier at path $fullPath") } + + if (foundedBundle?.bundleIdentifier == identifier) return foundedBundle } } - return bundleWithIdentifier(identifier) - ?: throw IllegalArgumentException("bundle with identifier $identifier not found") + throw IllegalArgumentException("bundle with identifier $identifier not found") } var isBundleSearchLogEnabled = false