Hi, I use shared code via swift package in iOS. I ...
# moko
a
Hi, I use shared code via swift package in iOS. I can successfully use moko-resources after adding the script to copy resources to app. Although I see the resources(Localizable.strings) included in the SPM bundle, why isn’t it possible to reach them without the script we use in xcode? What am I missing?
a
hi. custom script required only in case of
static
framework usage. if you change your framework to
isStatic = false
in gradle - your framework will save all bundles in application too. but static frameworks can't have any resources. it's not our limits - it's apple limits
a
I already use
isStatic = false
. Successfully call the resource like
OR.strings().my_string.desc().localized()
and run the app. But receiving following error after launch (without using the script):
Copy code
Uncaught Kotlin exception: kotlin.IllegalArgumentException: bundle with identifier <http://com.organtis.shared.MR|com.organtis.shared.MR> not found


    at 0   Organtis                            0x10bdf27c6        kfun:dev.icerock.moko.resources.utils#loadableBundle__at__platform.Foundation.NSBundle.Companion(kotlin.String){}platform.Foundation.NSBundle + 3734 
    at 1   Organtis                            0x10be1784c        kfun:com.organtis.shared.OR.$<init>$lambda$0$FUNCTION_REFERENCE$1.invoke#internal + 124 
    at 2   Organtis                            0x10bb5689b        kfun:kotlin.native.concurrent.SynchronizedLazyImpl#<get-value>(){}1:0 + 1211 
    at 3   Organtis                            0x10be0a41a        kfun:com.organtis.shared.OR.<get-bundle>#internal + 186 
    at 4   Organtis                            0x10be0a6fa        kfun:com.organtis.shared.OR.strings#<init>(){} + 714 
    at 5   Organtis                            0x10bfe33ff        objc2kotlin.2821 + 991 
    at 6   Organtis                            0x10b7bf0fa        $sSo15SharedORStringsCABycfCTO + 26 
    at 7   Organtis                            0x10b7be6f0        $s10HomeModule0A9PresenterC11prepareApps33_6E3CB8679A12B9E99F21727465D80D59LLyyF + 4096 
    at 8   Organtis                            0x10b7bf7d5        $s10HomeModule0A9PresenterC15createObserversyyFySo15SharedPagedListCySo0F3AppCGSgcfU0_ + 1125 
    at 9   Organtis                            0x10b6c2490        $s9CoreUtils12listenValues_9onLoading0E7Success0E5Error0E5Empty7Combine11Cancellable_pSo17SharedFlowAdapterCySo0L9ViewStateCyxGG_ySbcyxSgcySSSgcySbctRlzClFyAMcfU0_ + 352 
    at 10  Organtis                            0x10b6c2809        $s9CoreUtils12listenValues_9onLoading0E7Success0E5Error0E5Empty7Combine11Cancellable_pSo17SharedFlowAdapterCySo0L9ViewStateCyxGG_ySbcyxSgcySSSgcySbctRlzClFyAMcfU0_TA + 73 
    at 11  Combine                             0x10e4a0de2        $s7Combine11SubscribersO4SinkC7receiveyAC6DemandVxF + 82 
    at 12  Combine                             0x10e4a149f        $s7Combine11SubscribersO4SinkCy_xq_GAA10SubscriberA2aGP7receiveyAC6DemandV5InputQzFTW + 15 
    at 13  Combine                             0x10e4d83ae        $s7Combine10PublishersO9ReceiveOnV5Inner33_1178A6B2012BC46DB46053E713A746B4LLC7receiveyAA11SubscribersO6DemandV6OutputQzFyycfU_ + 222 
    at 14  libswiftDispatch.dylib              0x10eb24cc8        $sIeg_IeyB_TR + 24 
    at 15  libdispatch.dylib                   0x111efc815        _dispatch_call_block_and_release + 11 
    at 16  libdispatch.dylib                   0x111efda5a        _dispatch_client_callout + 7 
    at 17  libdispatch.dylib                   0x111f0c324        _dispatch_main_queue_drain + 1168 
    at 18  libdispatch.dylib                   0x111f0be85        _dispatch_main_queue_callback_4CF + 30 
    at 19  CoreFoundation                      0x1102c9ed4        __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8 
    at 20  CoreFoundation                      0x1102c46c9        __CFRunLoopRun + 2760 
    at 21  CoreFoundation                      0x1102c3703        CFRunLoopRunSpecific + 561 
    at 22  GraphicsServices                    0x11bd80c8d        GSEventRunModal + 138 
    at 23  UIKitCore                           0x12b04f659        -[UIApplication _run] + 927 
    at 24  UIKitCore                           0x12b0542b4        UIApplicationMain + 100 
    at 25  libswiftUIKit.dylib                 0x1100c4cc1        $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 97 
    at 26  Organtis                            0x10b5e6087        $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 103 
    at 27  Organtis                            0x10b5e6016        $s8Organtis11AppDelegateC5$mainyyFZ + 38 
    at 28  Organtis                            0x10b5e80a7        main + 23 
    at 29  dyld                                0x10d8b1f20        0x0 + 4522188576 
    at 30  ???                                 0x11c06351d        0x0 + 4765136157
a
show please gradle config where you set isStatic = false
a
Copy code
listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "Organtis"
            isStatic = false
            export("dev.icerock.moko:resources:0.20.1")
        }
    }
I feel like it doesn’t effect. Currently, using
0.20.1
and gradle
7.6
a
Maybe you have multiple framework compilations? One this with dynamic and one another for spm. Show please ./gradlew tasks of module where framework configured
a
🤦‍♂️ I think you’re right. I was supposing
multiplatformSwiftPackage
plugin is using the one I set above but not 🙂 On the other hand, I can’t make non-static because of
dev.gitlive:firebase-auth
need to find a solution for it first and then will give a try. Thank you so much 🙋‍♂️
d
@alex009 hello, seems like I have the same problem. I distribute xcFramework by using kmmbridge gradle plugin. In the iOs project can call SharedRes.strings().res_id, but receive exception
kotlin.IllegalArgumentException: bundle with identifier <http://com.organtis.shared.MR|com.organtis.shared.MR> not found
(running on simulator). Also, I can see bundle with generated strings in the xcframework. I attached shared module gradle tasks.
Copy code
listOf(
    iosX64(),
    iosArm64(),
    iosSimulatorArm64()
).forEach {
    it.binaries.framework {
        baseName = SHARE_BINARY_NAME
        export(libs.moko.shared.resources)
    }
}
gh action step:
Copy code
- name: Build Main
        run:
          ./gradlew kmmBridgePublish
Also, if I build xcFramework (assembleXCFramework) manually, I have the same issue. would appreciate for help, ty
a
@Dmitry Danilau set
isStatic = true
and try again when you build with
assembleXCFramework
instead of kmmbridge plugin.
1