Skip to content

Commit

Permalink
Revert "icerockdev#747 worked solution with static library inside"
Browse files Browse the repository at this point in the history
This reverts commit f308f1b.
  • Loading branch information
OskarPersson committed Dec 13, 2024
1 parent d3a8264 commit 8f26b52
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 206 deletions.
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ kotlin.mpp.stability.nowarn=true
kotlin.mpp.androidGradlePluginCompatibility.nowarn=true
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.mpp.applyDefaultHierarchyTemplate=false
kotlin.mpp.enableCInteropCommonization=true

org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion resources/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
id("multiplatform-library-extended-convention")
id("multiplatform-android-publish-convention")
id("apple-main-convention")
id("apple-bundle-searcher-convention")
id("detekt-convention")
id("javadoc-stub-convention")
id("publication-convention")
Expand Down
5 changes: 0 additions & 5 deletions resources/src/appleMain/def/bundleSearcher.def

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

package dev.icerock.moko.resources.utils

import dev.icerock.moko.resources.apple.native.ResourcesBundleAnchor
import kotlinx.cinterop.ExperimentalForeignApi
import platform.Foundation.NSBundle
import platform.Foundation.NSDirectoryEnumerator
import platform.Foundation.NSFileManager
Expand All @@ -14,16 +12,18 @@ import platform.Foundation.NSURL
import platform.Foundation.pathExtension

fun NSBundle.Companion.loadableBundle(identifier: String): NSBundle {
// we should use search by our class because dynamic framework with resources can be placed in
// external directory, not inside app directory (NSBundle.main). for example in case of
// SwiftUI preview - app directory empty, but dynamic framework with resources will be in
// different directory (DerivedData)
// more details inside resources-build-logic/src/main/kotlin/apple-bundle-searcher-convention.gradle.kts
@OptIn(ExperimentalForeignApi::class)
val rootBundle: NSBundle = requireNotNull(ResourcesBundleAnchor.getResourcesBundle()) {
"root NSBundle can't be found"
}
val bundlePath: String = rootBundle.bundlePath
// at first we try to find required bundle inside Bundle.main, because it's faster way
// https://github.com/icerockdev/moko-resources/issues/708
// but in some cases (for example in SwiftUI Previews) dynamic framework with bundles can be located
// in different location, not inside Bundle.main. So in this case we run less performant way - bundleWithIdentifier
// https://github.com/icerockdev/moko-resources/issues/747
return findBundleInMain(identifier)
?: NSBundle.bundleWithIdentifier(identifier)
?: throw IllegalArgumentException("bundle with identifier $identifier not found")
}

private fun findBundleInMain(identifier: String): NSBundle? {
val bundlePath: String = NSBundle.mainBundle.bundlePath

val enumerator: NSDirectoryEnumerator = requireNotNull(
NSFileManager.defaultManager.enumeratorAtPath(bundlePath)
Expand All @@ -46,7 +46,7 @@ fun NSBundle.Companion.loadableBundle(identifier: String): NSBundle {
}
}

throw IllegalArgumentException("bundle with identifier $identifier not found")
return null
}

var isBundleSearchLogEnabled = false
9 changes: 0 additions & 9 deletions resources/src/appleMain/objective-c/MRResourcesBundle.h

This file was deleted.

13 changes: 0 additions & 13 deletions resources/src/appleMain/objective-c/MRResourcesBundle.m

This file was deleted.

0 comments on commit 8f26b52

Please sign in to comment.