compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

When running iOS by defining cocoapods, the resources in the ComposeResource folder are not copied

Open carter-rs opened this issue 1 year ago • 7 comments

  • iOS

Versions

  • Kotlin version*: 1.9.22
  • Compose Multiplatform version*: 1.6.0-rc01

https://github.com/JetBrains/compose-multiplatform-ios-android-template

In the repository example, only the iOS settings section was changed to Cocoapods settings, so the contents of the ComposeRource folder were not copied when run.

스크린샷 2024-02-15 오후 2 09 59 스크린샷 2024-02-15 오후 2 11 23

carter-rs avatar Feb 15 '24 05:02 carter-rs

Hi! Did you migrate your Xcode project to the cocoapods as well?

terrakok avatar Feb 15 '24 14:02 terrakok

https://kotlinlang.org/docs/native-cocoapods.html

The guide section of the site has been applied. Are any additional settings required?

carter-rs avatar Feb 15 '24 23:02 carter-rs

When running on Android, the image is displayed normally, but on iOS, the image is not copied and a crash occurs.

Image( painterResource(Res.drawable.compose_multiplatform), null )

carter-rs avatar Feb 15 '24 23:02 carter-rs

you are suppose to close Xcode and call pod install again after first build. it is an issue with cocoapods that it needs generated resources on a disk to configure Xcode project properly

terrakok avatar Feb 16 '24 14:02 terrakok

In other words: shared.podspec contains a line spec.resources = ['build/compose/ios/shared/compose-resources'] but cocoapods ignore it if the directory is empty.

terrakok avatar Feb 16 '24 14:02 terrakok

Cocoapods ignore it if the directory is empty. I don't understand. Please see the links to related samples below.

https://github.com/carter-rs/compose-multiplatform-ios-android-template-main

carter-rs avatar Feb 19 '24 00:02 carter-rs

When using the cocoapods framework, the two Tasks checkCanSyncPodComposeResourcesForIos and syncPodComposeResourcesForIos are not called.

carter-rs avatar Feb 19 '24 03:02 carter-rs

As i said before you have to call the 'pod install' command in the ios dir after the first build

terrakok avatar Feb 24 '24 17:02 terrakok

I'm having the same issue and I think I'm doing a pod install after the first ios build (even after an android build)

I fail to see what am I missing.

Shusshu avatar Apr 12 '24 21:04 Shusshu

@Shusshu could you check your podspec file and if it declares the resources dir then check it as well

terrakok avatar Apr 13 '24 06:04 terrakok

My setup it slightly different as I have a shared UI within the compose module, I only need cocoapods to setup GoogleMaps - Without cocoapods everything was working fine.

spec.resources = ['build/compose/ios/composeApp/compose-resources']

Which task is supposed to fill that directory? It used to contain the fonts, strings, etc - still the iOS app was crashing as it couldn't find the resources.

After cleaning that directory, I wasn't able to generate it again during build.

Shusshu avatar Apr 13 '24 07:04 Shusshu

How do you integrate the podspec to your xcproject?

terrakok avatar Apr 13 '24 18:04 terrakok

Thank you very much, I tried so many things so late it was getting ridiculous.

Your question nailed it, I re-added pod 'composeApp', :path => '../composeApp' into the podfile and 💥 it works as expected.

Shusshu avatar Apr 13 '24 19:04 Shusshu

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

okushnikov avatar Jul 14 '24 15:07 okushnikov