https://kotlinlang.org logo
Title
u

Uli Niggemann

05/22/2023, 2:27 PM
Hello, I am evaluating Moko-Resources for our kmp project. It works well in android, but I got the following when launching the compose-multiplatform view with an ios-simulator
Can't read color textColor from bundle NSBundle ....bundle> (not yet loaded), please check moko-resources gradle configuration
The module is static due to compose-multiplatform and I have added the Build-Phase for cocoapods-usage… So what could possibly go wrong? 😉 Do you have any ideas what I am missing?
a

alex009

05/22/2023, 3:10 PM
hi. check please in your ios
.app
file it contains
.bundle
with your resources class package
if not contains - check is
framework
in gradle build directory contains it
if framework not contains - check is you enable gradle plugin in gradle project that have compilation of framework
if framework contains but app not contains - check is you correct setup build phase? maybe this build phase write some errors in log?
u

Uli Niggemann

05/22/2023, 3:15 PM
Hi Aleksey, the bundle is there. And it looks like all the resources are there, too
the runtime-error say
(not yet loaded)
a

alex009

05/22/2023, 3:16 PM
hmm
u

Uli Niggemann

05/22/2023, 3:16 PM
more specific
*my_lib.bundle> (not yet loaded), please check moko-resources gradle configuration*
a

alex009

05/22/2023, 3:22 PM
all resources on ios at first access load bundle - https://github.com/icerockdev/moko-resources/blob/6bf37f44410e7c4b8316a515810466bd[…]ppleMain/kotlin/dev/icerock/moko/resources/utils/NSBundleExt.kt and then works with this bundle. but i think if you have in multiple bundles same identifier you can confuse this logic
you have multiple bundles or single?
also maybe problem not with bundle. https://developer.apple.com/documentation/uikit/uicolor/2877381-colornamed this error can be if this method return
nil
. i think it's not related to
bundle
- we already found
bundle
but get of color not work
u

Uli Niggemann

05/22/2023, 3:30 PM
there is only one bundle. Do I have to trigger the loading manually if I am using compose-multiplatform?
a

alex009

05/22/2023, 3:32 PM
it's load automatically. error message is invalid - here not only loading bundle issue can be
can you give me color resource config?
string, colors, images are working in android
(unfortunately i will be a little more unresponsive from now on, as i have to leave) but thanks a lot for your help!
a

alex009

05/22/2023, 3:43 PM
you compare config of your project with sample? now i try to configure static framework and check...
here https://github.com/icerockdev/moko-compose-multiplatform-ios-android-template i setup static framework and not see this issue. can you check please? if you can reproduce error - create please sample
u

Uli Niggemann

05/23/2023, 9:10 AM
Good morning @alex009. The example is crashing as well…
May it be related to my m1Mac?
a

alex009

05/23/2023, 9:11 AM
strange, on my ios simulator it works. i have m1 max
u

Uli Niggemann

05/23/2023, 9:11 AM
same here
a

alex009

05/23/2023, 9:11 AM
describe all test environment please. ios simulator or device ios version xcode version
u

Uli Niggemann

05/23/2023, 9:13 AM
sure, mom
xcode Version 14.3 (14E222b) simulator iPadMini (6th Gen) 16.4 or iPhoneX 16.1.2 (20B110)
a

alex009

05/23/2023, 9:15 AM
i now have xcode 14.1
i test later this simulators with this versions. if not reproduce - i download 14.3
u

Uli Niggemann

05/23/2023, 9:16 AM
wait a minute, i’ll test
(i have 14.1 installed as well)
Maybe it is just the bundle name? in your case “MyApplication/shared.bundle” - this should be a invalid filename
a

alex009

05/23/2023, 9:19 AM
but on my machine all works)
so it's not just filename problem
u

Uli Niggemann

05/23/2023, 9:19 AM
It also crashes with 14.1…
a

alex009

05/23/2023, 9:21 AM
now i run on 16.1 ios
u

Uli Niggemann

05/23/2023, 9:21 AM
could you please have a look at
Bundle.allBundles
at runtime?
the desired bundle is not listed
a

alex009

05/23/2023, 9:22 AM
send me copy of code please 🙂
u

Uli Niggemann

05/23/2023, 9:22 AM
print(Bundle.allBundles)
will do
a

alex009

05/23/2023, 9:23 AM
loading of bundle is lazy
you try to read bundle list before MR was loaded
print(Bundle.allBundles) let bundle = MR.images.shared.nsBundle print(bundle) print(Bundle.allBundles)
u

Uli Niggemann

05/23/2023, 9:26 AM
ah sorry, you are right
a

alex009

05/23/2023, 9:27 AM
print(Bundle.allBundles)
        let colors = MR.colors.shared
        print(colors.nsBundle)
        print(colors.textColor.bundle)
        print(Bundle.allBundles)
        
        let color = UIColor(
            named: colors.textColor.name,
            in: colors.textColor.bundle,
            compatibleWith: nil
        )
        print("color: \(color)")
try this
i successful got color
u

Uli Niggemann

05/23/2023, 9:27 AM
mom
a

alex009

05/23/2023, 9:27 AM
Untitled
u

Uli Niggemann

05/23/2023, 9:28 AM
the bundle is found, but not the color
[NSBundle </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/BoundingPathData.bundle> (not yet loaded), NSBundle </Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/F70B4CDA-2D4A-43E2-A6CE-2D1D68923616/My application.app> (loaded)]
NSBundle </Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/F70B4CDA-2D4A-43E2-A6CE-2D1D68923616/My application.app/MyApplication:shared.bundle> (not yet loaded)
NSBundle </Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/F70B4CDA-2D4A-43E2-A6CE-2D1D68923616/My application.app/MyApplication:shared.bundle> (not yet loaded)
[NSBundle </Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/F70B4CDA-2D4A-43E2-A6CE-2D1D68923616/My application.app/MyApplication:shared.bundle> (not yet loaded), NSBundle </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/BoundingPathData.bundle> (not yet loaded), NSBundle </Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/F70B4CDA-2D4A-43E2-A6CE-2D1D68923616/My application.app> (loaded)]
color: nil
a

alex009

05/23/2023, 9:28 AM
i think something wrong with
compatibleWith
parameter...
u

Uli Niggemann

05/23/2023, 9:30 AM
could the kotlin or gradle-version matter?
a

alex009

05/23/2023, 9:30 AM
i think not
also we both test on same code
so problem in enviroment. something different and same code give different results
https://stackoverflow.com/a/74189389/9931244 in native ios same problem resolve by just build cleanup 😄
let color = UIColor(
            named: colors.textColor.name,
            in: colors.textColor.bundle,
            compatibleWith: UITraitCollection.current
        )
check this?
print("traits: \(UITraitCollection.current)")
and this
u

Uli Niggemann

05/23/2023, 9:34 AM
no, still the same
a

alex009

05/23/2023, 9:35 AM
i see
traits: <UITraitCollection: 0x600003e5f500; UserInterfaceIdiom = Phone, DisplayScale = 3, DisplayGamut = P3, HorizontalSizeClass = Compact, VerticalSizeClass = Regular, UserInterfaceStyle = Light, UserInterfaceLayoutDirection = LTR, ForceTouchCapability = Unavailable, PreferredContentSizeCategory = L, AccessibilityContrast = Normal, UserInterfaceLevel = Base>
u

Uli Niggemann

05/23/2023, 9:35 AM
may it be a race-condition?
[NSBundle </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/BoundingPathData.bundle> (not yet loaded), NSBundle </Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/D54E186D-D3A7-4882-A965-36ED410F0579/My application.app> (loaded)]
NSBundle </Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/D54E186D-D3A7-4882-A965-36ED410F0579/My application.app/MyApplication:shared.bundle> (not yet loaded)
NSBundle </Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/D54E186D-D3A7-4882-A965-36ED410F0579/My application.app/MyApplication:shared.bundle> (not yet loaded)
[NSBundle </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/BoundingPathData.bundle> (not yet loaded), NSBundle </Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/D54E186D-D3A7-4882-A965-36ED410F0579/My application.app> (loaded), NSBundle </Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/D54E186D-D3A7-4882-A965-36ED410F0579/My application.app/MyApplication:shared.bundle> (not yet loaded)]
color: nil
The bundle is there, but not loaded
…yet
a

alex009

05/23/2023, 9:36 AM
in my logs it "not yet loaded" too
u

Uli Niggemann

05/23/2023, 9:37 AM
hm, ok
but still: is MyApplication:shared.bundle == MyApplication/shared.bundle
your naming is the same, isn’t it?
a

alex009

05/23/2023, 9:38 AM
NSBundle </Users/amikhailov/Library/Developer/CoreSimulator/Devices/5C91DD9B-AE1A-4BB5-A58B-ED2D322D691D/data/Containers/Bundle/Application/3D530DCE-1D31-4BF9-A871-E19E2FD8E856/My application.app/My application:shared.bundle> (not yet loaded)
it's bundle that resources found and there contains color
u

Uli Niggemann

05/23/2023, 9:39 AM
sorry, missed it - mom
traits: <UITraitCollection: 0x600001677000; UserInterfaceIdiom = Phone, DisplayScale = 3, DisplayGamut = P3, HorizontalSizeClass = Compact, VerticalSizeClass = Regular, UserInterfaceStyle = Light, UserInterfaceLayoutDirection = LTR, ForceTouchCapability = Unavailable, PreferredContentSizeCategory = L, AccessibilityContrast = Normal, UserInterfaceLevel = Base>
a

alex009

05/23/2023, 9:40 AM
so and traits is same...
let files = colors.textColor.bundle
            .paths(forResourcesOfType: nil, inDirectory: nil)
            .forEach { print($0) }
try this too
u

Uli Niggemann

05/23/2023, 9:43 AM
is your “physical” bundle also called MyApplication/shared.bundle?
a

alex009

05/23/2023, 9:44 AM
My <http://application.app/My|application.app/My> application:shared.bundle/Contents/Resources/en.lproj
My <http://application.app/My|application.app/My> application:shared.bundle/Contents/Resources/Base.lproj
My <http://application.app/My|application.app/My> application:shared.bundle/Contents/Resources/Assets.car
My <http://application.app/My|application.app/My> application:shared.bundle/Contents/Resources/cormorant-italic.otf
My <http://application.app/My|application.app/My> application:shared.bundle/Contents/Resources/ru.lproj
My <http://application.app/My|application.app/My> application:shared.bundle/Contents/Resources/files
My <http://application.app/My|application.app/My> application:shared.bundle/Contents/Resources/some_asset.txt
My <http://application.app/My|application.app/My> application:shared.bundle/Contents/Resources/en.lproj/Localizable.strings
My <http://application.app/My|application.app/My> application:shared.bundle/Contents/Resources/en.lproj/Localizable.stringsdict
here mu output
u

Uli Niggemann

05/23/2023, 9:44 AM
color: nil
/Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/DFA331F4-F81B-4EDD-AD64-8388F0C8108D/My <http://application.app/MyApplication:shared.bundle/Contents/Resources/en.lproj|application.app/MyApplication:shared.bundle/Contents/Resources/en.lproj>
/Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/DFA331F4-F81B-4EDD-AD64-8388F0C8108D/My <http://application.app/MyApplication:shared.bundle/Contents/Resources/Assets.xcassets|application.app/MyApplication:shared.bundle/Contents/Resources/Assets.xcassets>
/Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/DFA331F4-F81B-4EDD-AD64-8388F0C8108D/My <http://application.app/MyApplication:shared.bundle/Contents/Resources/Base.lproj|application.app/MyApplication:shared.bundle/Contents/Resources/Base.lproj>
/Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/DFA331F4-F81B-4EDD-AD64-8388F0C8108D/My <http://application.app/MyApplication:shared.bundle/Contents/Resources/cormorant-italic.otf|application.app/MyApplication:shared.bundle/Contents/Resources/cormorant-italic.otf>
/Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/DFA331F4-F81B-4EDD-AD64-8388F0C8108D/My <http://application.app/MyApplication:shared.bundle/Contents/Resources/ru.lproj|application.app/MyApplication:shared.bundle/Contents/Resources/ru.lproj>
/Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/DFA331F4-F81B-4EDD-AD64-8388F0C8108D/My <http://application.app/MyApplication:shared.bundle/Contents/Resources/files|application.app/MyApplication:shared.bundle/Contents/Resources/files>
/Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/DFA331F4-F81B-4EDD-AD64-8388F0C8108D/My <http://application.app/MyApplication:shared.bundle/Contents/Resources/some_asset.txt|application.app/MyApplication:shared.bundle/Contents/Resources/some_asset.txt>
/Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/DFA331F4-F81B-4EDD-AD64-8388F0C8108D/My <http://application.app/MyApplication:shared.bundle/Contents/Resources/en.lproj/Localizable.strings|application.app/MyApplication:shared.bundle/Contents/Resources/en.lproj/Localizable.strings>
/Users/niggeulimann/Library/Developer/CoreSimulator/Devices/67421313-8A0F-45F4-94C2-ED5DCE7BFD74/data/Containers/Bundle/Application/DFA331F4-F81B-4EDD-AD64-8388F0C8108D/My <http://application.app/MyApplication:shared.bundle/Contents/Resources/en.lproj/Localizable.stringsdict|application.app/MyApplication:shared.bundle/Contents/Resources/en.lproj/Localizable.stringsdict>
ah
your bundle name is different
a

alex009

05/23/2023, 9:45 AM
hmmmmm
oh, i got crash. after clean of gradle and xcode caches
so for me works old bundled from dynamic framework configurations i think
u

Uli Niggemann

05/23/2023, 9:47 AM
sorry to say, but that’s good 😉
a

alex009

05/23/2023, 9:47 AM
Untitled
yes, it's good
so i think we have some diff between bundles for static framework and bundles for dynamic framework oO
in broken bundle Assets not compiled
and same not compiled assets located in gradle cocoapods dir. so it's some gradle plugin problem
u

Uli Niggemann

05/23/2023, 9:54 AM
but this looks good on my side
a

alex009

05/23/2023, 9:54 AM
xcassets - is not compiled version
compiled is
car
u

Uli Niggemann

05/23/2023, 9:54 AM
ups 😳
so it is something in
copyFrameworkResourcesToApp
and the bundle could not be loaded because of this?
a

alex009

05/23/2023, 10:02 AM
no. problem in bundle packaging. i already found bug and now prepare for release bugfix
0.22.2 published. please check
u

Uli Niggemann

05/23/2023, 1:28 PM
Yes, it works! ❤️ Thanks a lot!
a

alex009

05/23/2023, 1:28 PM
thanks for help in debugging
u

Uli Niggemann

05/23/2023, 1:31 PM
No, thank you. That’s really great. I think this will save us a lot of time, the idea is great.
Now we can face the next big requirement which is multi brand resources 🙈