Skip to content

Commit

Permalink
#747 rollback to old search way but still failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex009 committed Dec 7, 2024
1 parent 7a2bc6e commit 6cc8055
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 87 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
17 changes: 0 additions & 17 deletions resources/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
* Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins {
id("multiplatform-library-extended-convention")
id("multiplatform-android-publish-convention")
Expand All @@ -28,20 +25,6 @@ kotlin {
}
}
}

// setup bundle searcher for apple
// targets
// .withType<KotlinNativeTarget>()
// .matching { it.konanTarget.family.isAppleFamily }
// .configureEach {
// compilations.getByName(KotlinCompilation.MAIN_COMPILATION_NAME) {
// val appleNative by cinterops.creating {
// defFile(project.file("src/appleMain/def/appleNative.def"))
//
// includeDirs("$projectDir/src/appleMain/objective-c")
// }
// }
// }
}

android {
Expand Down
5 changes: 0 additions & 5 deletions resources/src/appleMain/def/appleNative.def

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +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)
val bundlePath: String = MRBundleAnchor().getBundle().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 @@ -39,7 +46,7 @@ fun NSBundle.Companion.loadableBundle(identifier: String): NSBundle {
}
}

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

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

This file was deleted.

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

This file was deleted.

0 comments on commit 6cc8055

Please sign in to comment.