Hello, I am evaluating Moko-Resources for our kmp ...
# moko
u
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
Copy code
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
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
Hi Aleksey, the bundle is there. And it looks like all the resources are there, too
the runtime-error say
(not yet loaded)
a
hmm
u
more specific
*my_lib.bundle> (not yet loaded), please check moko-resources gradle configuration*
a
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
there is only one bundle. Do I have to trigger the loading manually if I am using compose-multiplatform?
a
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
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
Good morning @alex009. The example is crashing as well…
May it be related to my m1Mac?
a
strange, on my ios simulator it works. i have m1 max
u
same here
a
describe all test environment please. ios simulator or device ios version xcode version
u
sure, mom
xcode Version 14.3 (14E222b) simulator iPadMini (6th Gen) 16.4 or iPhoneX 16.1.2 (20B110)
a
i now have xcode 14.1
i test later this simulators with this versions. if not reproduce - i download 14.3
u
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
but on my machine all works)
so it's not just filename problem
u
It also crashes with 14.1…
a
now i run on 16.1 ios
u
could you please have a look at
Bundle.allBundles
at runtime?
the desired bundle is not listed
a
send me copy of code please 🙂
u
print(Bundle.allBundles)
will do
a
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
ah sorry, you are right
a
Copy code
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
mom
a
Untitled
u
the bundle is found, but not the color
Copy code
[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
i think something wrong with
compatibleWith
parameter...
u
could the kotlin or gradle-version matter?
a
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 😄
Copy code
let color = UIColor(
            named: colors.textColor.name,
            in: colors.textColor.bundle,
            compatibleWith: UITraitCollection.current
        )
check this?
Copy code
print("traits: \(UITraitCollection.current)")
and this
u
no, still the same
a
i see
Copy code
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
may it be a race-condition?
Copy code
[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
in my logs it "not yet loaded" too
u
hm, ok
but still: is MyApplication:shared.bundle == MyApplication/shared.bundle
your naming is the same, isn’t it?
a
Copy code
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
sorry, missed it - mom
Copy code
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
so and traits is same...
Copy code
let files = colors.textColor.bundle
            .paths(forResourcesOfType: nil, inDirectory: nil)
            .forEach { print($0) }
try this too
u
is your “physical” bundle also called MyApplication/shared.bundle?
a
Copy code
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
Copy code
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
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
sorry to say, but that’s good 😉
a
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
but this looks good on my side
a
xcassets - is not compiled version
compiled is
car
u
ups 😳
so it is something in
copyFrameworkResourcesToApp
and the bundle could not be loaded because of this?
a
no. problem in bundle packaging. i already found bug and now prepare for release bugfix
0.22.2 published. please check
u
Yes, it works! ❤️ Thanks a lot!
a
thanks for help in debugging
u
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 🙈
444 Views