ismai117 / kottie

Render After Effects Animations Library - Compose Multiplatform | Inspired by Airbnb/Lottie
Apache License 2.0
192 stars 8 forks source link

XCode : framework 'Lottie' not found #2

Closed Clemodd closed 7 months ago

Clemodd commented 7 months ago

Hi,

I've added Kottie to a project. It's working for Android, Windows, Mac, but not with the Iphone.. :(

I have this error on Xcode only :

ld: warning: Could not find or use auto-linked framework 'Lottie': framework 'Lottie' not found ld: Undefined symbols: _OBJCCLASS$__TtC6Lottie19CompatibleAnimation, referenced from: in composeApp2646 _OBJCCLASS$__TtC6Lottie23CompatibleAnimationView, referenced from: in composeApp2646 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I don't have Lottie on my project, just Kottie.

Here the implementation : @Composable fun SplashScreenComposable( test: String? = null ) { Surface( color = LocalCouleurPalette.current.fondEcran, modifier = Modifier.fillMaxSize() ) { Text( text = "SplashScreen $test", color = LocalCouleurPalette.current.texte, modifier = Modifier.fillMaxSize() ) val composition = rememberKottieComposition( spec = KottieCompositionSpec.File("raw/wea_chargement.json") )

    val animationState by animateKottieCompositionAsState(
        composition = composition,
        speed = 1f,
        iterations = 2
    )

    KottieAnimation(
        composition = composition,
        progress = { animationState.progress },
        modifier = Modifier.fillMaxSize(),
    )
}

Thank you for your help :) 
ismai117 commented 7 months ago

Unfortunately, you have to add cocoapods to your project. 

cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "14.1"
        podfile = project.file("../iosApp/Podfile")
        pod("lottie-ios") {
            version = "4.4.0"
            linkOnly = true
        }
 }

let me know if it works

Clemodd commented 7 months ago

Hi,

Thank you for your anwser. It's a project Kotlin multiplatform and Compose multiplatform. So the UI is shared between Android and IOS. And it doesn't have Cocoapods.. I tried to add it, but i don't know what to put into the Podfile.

Do you know if it's possible to add cocoapods into a project compose multiplatform ?

Thank you. 🙌

ismai117 commented 7 months ago

Check this out, add cocoapods https://github.com/ismai117/DroidJobsKMP/blob/master/composeApp%2Fbuild.gradle.kts

Once that's done, Open terminal, Inside the iOS app directory, follow these steps

1) pod init 2) pod install

Clemodd commented 7 months ago

Thank you,

I've copied the references of DroidJobsKMP to my project, everything runs and Android studios, i did 'pod init', 'pod install', I have the Podfile filled, but with xcode, i have this error when i build :

Ld /Users/clement_jum/Library/Developer/Xcode/DerivedData/iosApp-grfjzbbuclquhrepxuyzqlpxmvmh/Build/Products/Debug-iphonesimulator/Weaverly.app/Weaverly normal (in target 'iosApp' from project 'iosApp')
    cd /Users/clement_jum/Documents/Projets/weaverly/iosApp
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target x86_64-apple-ios14.1-simulator -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.2.sdk -O0 -L/Users/clement_jum/Library/Developer/Xcode/DerivedData/iosApp-grfjzbbuclquhrepxuyzqlpxmvmh/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -L/Users/clement_jum/Library/Developer/Xcode/DerivedData/iosApp-grfjzbbuclquhrepxuyzqlpxmvmh/Build/Products/Debug-iphonesimulator -L/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.2.sdk/usr/lib/swift -F/Users/clement_jum/Library/Developer/Xcode/DerivedData/iosApp-grfjzbbuclquhrepxuyzqlpxmvmh/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -F/Users/clement_jum/Library/Developer/Xcode/DerivedData/iosApp-grfjzbbuclquhrepxuyzqlpxmvmh/Build/Products/Debug-iphonesimulator -F/Users/clement_jum/Documents/Projets/weaverly/iosApp/../shared/build/xcode-frameworks/Debug/iphonesimulator17.2 -F/Users/clement_jum/Documents/Projets/weaverly/iosApp/../composeApp/build/xcode-frameworks/Debug/iphonesimulator17.2 -filelist /Users/clement_jum/Library/Developer/Xcode/DerivedData/iosApp-grfjzbbuclquhrepxuyzqlpxmvmh/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/iosApp.build/Objects-normal/x86_64/Weaverly.LinkFileList -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/clement_jum/Library/Developer/Xcode/DerivedData/iosApp-grfjzbbuclquhrepxuyzqlpxmvmh/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/iosApp.build/Objects-normal/x86_64/Weaverly_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -L/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/clement_jum/Library/Developer/Xcode/DerivedData/iosApp-grfjzbbuclquhrepxuyzqlpxmvmh/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/iosApp.build/Objects-normal/x86_64/Weaverly.swiftmodule -lc++ -framework CoreGraphics -framework Lottie -framework QuartzCore -framework UIKit -framework composeApp -weak_framework Combine -weak_framework SwiftUI -framework composeApp -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/clement_jum/Library/Developer/Xcode/DerivedData/iosApp-grfjzbbuclquhrepxuyzqlpxmvmh/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/iosApp.build/Weaverly.app-Simulated.xcent -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __ents_der -Xlinker /Users/clement_jum/Library/Developer/Xcode/DerivedData/iosApp-grfjzbbuclquhrepxuyzqlpxmvmh/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/iosApp.build/Weaverly.app-Simulated.xcent.der -framework Pods_iosApp -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/clement_jum/Library/Developer/Xcode/DerivedData/iosApp-grfjzbbuclquhrepxuyzqlpxmvmh/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/iosApp.build/Objects-normal/x86_64/Weaverly_dependency_info.dat -o /Users/clement_jum/Library/Developer/Xcode/DerivedData/iosApp-grfjzbbuclquhrepxuyzqlpxmvmh/Build/Products/Debug-iphonesimulator/Weaverly.app/Weaverly

And this :

ld: warning: search path '/Users/clement_jum/Documents/Projets/weaverly/iosApp/../shared/build/xcode-frameworks/Debug/iphonesimulator17.2' not found ld: framework 'Lottie' not found clang: error: linker command failed with exit code 1 (use -v to see invocation)

I don't understand nothing to this... Because i've added this to my project :

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.androidApplication)
    alias(libs.plugins.jetbrainsCompose)
    alias(libs.plugins.kotlinx.serialization)
    alias(libs.plugins.kover) // Pour le coverage des tests
    alias(libs.plugins.cocoapods)
}

kotlin {
    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "14.1"
        podfile = project.file("../iosApp/Podfile")
        pod("lottie-ios") {
            version = "4.4.0"
            linkOnly = true
        }
    }

    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "11"
            }
        }
    }

And podfile is like yours..

Thank you so much for your help !

ismai117 commented 7 months ago

when you're using cocoapods, change the iOS configurations when running your app. so open xcworkspace file. once opened wait until the project scheme is generated.

step1 step2

if it still shows " framework 'Lottie' not found", run "pod install" command but this time don't run pod init

Clemodd commented 7 months ago

I did it and now the app is running on the emulator from xcode !

But the animation from lottie isn't loading with the Emulator. I have this error : Error when decoding animation "raw/weaverly_chargement.json": assetNotFound(name: "raw/weaverly_chargement", bundle: Optional(NSBundle </Users/clement_jum/Library/Developer/CoreSimulator/Devices/825D1C6C-3FE5-4064-A7E6-12DA9C65594A/data/Containers/Bundle/Application/CA653AA0-9726-43C1-ADE8-2B430E95A8D6/Weaverly.app> (loaded)))

Here a screenshot of the structure.

Capture d’écran 2024-02-20 à 09 16 18

Do you have any idea ? Here the Podfile : target 'iosApp' do use_frameworks! platform :ios, '14.1' pod 'lottie-ios', '~> 4.4.0' pod 'composeApp', :path => '../composeApp' end Thank you for your help !

ismai117 commented 7 months ago

show me your code please, I want to see how you've implemented it

Clemodd commented 7 months ago

Here is the project with kottie and the things you told me to do.

https://github.com/Clemodd/weaverly/tree/develop

Thank you a lot

ismai117 commented 7 months ago

oh ok, you're using version 1.4.3, so add the json file to iosApp assets folder in Xcode.

This step is not necessary if you're using the latest pre-release versions

Clemodd commented 7 months ago

I tried to add the json file on the Assets with the raw folder, but it wasn't working.. :(

So i tried to put the version of Kottie at 3.0.0-wasm2.

But i have these problem now.. In Android studio :

1: Task failed with an exception.

ismai117 commented 7 months ago

make sure to add

maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental") in settings.gradle

Clemodd commented 7 months ago

Thank you so much for your help.

When i put it, it was working, but weirdly, just parts of the animation.. And with the wasm/experimental, i have problems when i wanna run the desktop on mac.

I think i'll wait some time before putting Animation on my screens, when a stable release will be out.

But thank you for your help. Really 💯