Hello, I’ve created a module shared-ui-compose to ...
# compose-ios
g
Hello, I’ve created a module shared-ui-compose to share composables between Android, Desktop and iOS. Setup seems ok and I can import the module on iOS side (cocopods) but when I build I’ve this error:
Copy code
> Task :shared-ui-compose:compileKotlinIosSimulatorArm64 UP-TO-DATE
> Task :shared-ui-compose:linkPodDebugFrameworkIosSimulatorArm64 error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors

The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
I’ve seen this thread and issues 2346 2694, but it seems latest compose/kotlin versions solved their issue. I’m using:
Copy code
Kotlin 1.9.0
Jetbrains Compose 1.5.0-dev1074 (tried also with 1.4.3)
Jetbrains Compose Compiler 1.5.0
Any hint?
👍 1
1
don’t know if it is related:
Copy code
Undefined symbols for architecture arm64:
  "_CTFontCollectionCreateFromAvailableFonts", referenced from:
      SkFontMgr_Mac::SkFontMgr_Mac(__CTFontCollection const*) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
  "_CTFontCollectionCreateMatchingFontDescriptors", referenced from:
      (anonymous namespace)::SkCopyAvailableFontFamilyNames(__CTFontCollection const*) in 
…….
  "_kCTFontWeightTrait", referenced from:
      create_descriptor(char const*, SkFontStyle const&) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      SkCTFontDescriptorGetSkFontStyle(__CTFontDescriptor const*, bool) in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkCTFontGetDataFontWeightMapping() in libskia.a(libskia.SkCTFont.o)å
  "_kCTFontWidthTrait", referenced fårom:
      create_descriptor(char const*, SkFontStyle const&) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      SkCTFontDescriptorGetSkFontStyle(__CTFontDescriptor const*, bool) in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
ld: symbol(s) not found for architecture arm64

FAILURE: Build failed with an exception.
looks like making
isStatic = true
instead of
false
made it work 🤔 why?
d
Yes, for now we have a problem with dynamic frameworks. But, we will fix it
you should use isStatic = true
g
this will affect SwiftUi previews right?
d
Since version of Compose 1.5.0-beta01, you can use isStatic = false as well. Made sample here: https://github.com/dima-avdeev-jb/is-static-false
Proper instuctions how to upgrade to Compose 1.5.0-beta01 ypu can find here: https://kotlinlang.slack.com/archives/C0346LWVBJ4/p1690986896746479
@Guilherme Delgado If you have problems with version 1.5.0-beta01, can you please add to gradle.properties this line:
org.gradle.logging.level=info
And attach Gradle logs to this thread
g
Ok I’ll try it, let me share with you my setup so that you can see if I’m making mistakes:
Copy code
pluginManagement {
    includeBuild("build-logic")
    repositories {
        google()
        gradlePluginPortal()
        mavenCentral()
        maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
    }
}

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
        maven("<https://androidx.dev/storage/compose-compiler/repository/>")
    }
}
Copy code
composeMultiplatformCompiler = "1.5.0"
composeMultiplatform = "1.5.0-dev1074"
jetbrains-compose-multiplatform = { id = "org.jetbrains.compose", version.ref = "composeMultiplatform" }
Copy code
plugins {
    ...
    alias(libs.plugins.jetbrains.compose.multiplatform)
}

compose {
    kotlinCompilerPlugin.set(libs.versions.composeMultiplatformCompiler)
//    kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=1.9.0")
}
this is working, but if I change
1.5.0-dev1074
to
1.5.0-beta01
it will fail
```* What went wrong:
An exception occurred applying plugin request [id: 'org.jetbrains.compose', version: '1.5.0-beta01']
> Failed to apply plugin 'org.jetbrains.compose'.
> class org.jetbrains.compose.ComposeMultiplatformBuildService$Inject cannot be cast to class org.jetbrains.compose.ComposeMultiplatformBuildService (org.jetbrains.compose.ComposeMultiplatformBuildService$Inject is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @3380048a; org.jetbrains.compose.ComposeMultiplatformBuildService is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @2ce91950)```
d
Can you provide a minimal reproducible sample project on GitHub ?
g
sure let me just clean up and I’ll push it and notify you
👍 1
thank you color 1
a
@Guilherme Delgado can you add compose multiplatform Gradle plugin to your root build script here https://github.com/GuilhE/Expressus/blob/feature/compose-ios/build.gradle.kts#L9 The entry should point to
org.jetbrains.compose:compose-gradle-plugin
Copy code
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath(libs.gradle.android.tools)
        classpath(libs.gradle.kotlin)
        classpath(libs.gradle.kotlin.serialization)
        classpath(libs.gradle.kotlin.serialization)
        classpath("org.jetbrains.compose:compose-gradle-plugin:1.5.0-beta01")
    }
}
I generally recommend to list all of plugins in the root build script (either via
buildscript
or using plugins DSL). That way you can be sure that there are no classloding issues
g
so basically specifying the version in the classpath and then in each build.gradle.kts only adding
id("org.jetbrains.compose")
in this case?
(it worked)
a
so basically specifying the version in the classpath and then in each build.gradle.kts only adding
id("org.jetbrains.compose")
in this case?
• Yes
(it worked)
@Guilherme Delgado just to clarify: do you mean that everything builds with
1.5.0-beta01
?
g
yup, iOS & Desktop
a
Good to know, thank you!
g
also, removed static = true and extraSpecAttributes
and it works 😉
not seeing the SwiftUi previews though
Screenshot 2023-08-10 at 17.19.14.png
(but it is, I can import and run the apps)
could be unrelated I don’t know 😅
d
Preview with Compose in SwiftUI not works. We planning to do separate functionallity for preview of Compose part on iOS, but it is not a first priority Issue.
g
In my iosApp I’ve SwiftUi views that I could see their preview, but now I can’t.
Copy code
Library not loaded: @rpath/Shared.framework/Shared
Referenced from: <284B6553-3E94-3B15-8954-7FB0F1D0D8E5> /Users/USER/Library/Developer/Xcode/UserData/Previews/Simulator Devices/979993FB-71EB-4605-82CE-1B5137A6F788/data/Containers/Bundle/Application/1B2FEE8E-D276-4BA9-AB02-89943E4FF910/iosApp.app/iosApp
Reason: tried: '/Users/guilhermedelgado/Library/Developer/Xcode/DerivedData/iosApp-bluqxibulbhynkcxkkrpnzhenswq/Build/Intermediates.noindex/Previews/iosApp/Products/Debug-iphonesimulator/Shared.framework/Shared' (no such file), '/Users/guilhermedelgado/Library/Developer/Xcode/UserData/Previews/Simulator Devices/979993FB-71EB-4605-82CE-1B5137A6F788/data/Containers/Bundle/Application/1B2FEE8E-D276-4BA9-AB02-89943E4FF910/iosApp.app/Frameworks/Shared.framework/Shared' (no such file), '/Users/guilhermedelgado/Library/Developer/Xcode/UserData/Previews/Simulator Devices/979993FB-71EB-4605-82CE-1B5137A6F788/data/Containers/Bundle/Application/1B2FEE8E-D276-4BA9-AB02-89943E4FF910/iosApp.app/Frameworks/
(terminated at launch; ignore backtrace)
I remember in the past I had to make
isStatic = false
to have SwiftUi Previews. But now it’s false by default and it’s failing 😓
Ok it’s working, just deleted Derived Data 😉
Preview with Compose in SwiftUI not works. We planning to do separate functionallity for preview of Compose part on iOS, but it is not a first priority Issue.
@Dima Avdeev It’s working 😅 I can see it!