livekit / client-sdk-swift

LiveKit Swift Client SDK. Easily build live audio or video experiences into your mobile app, game or website.
https://livekit.io
Apache License 2.0
173 stars 84 forks source link

App Crashes with Library not loaded: @rpath/WebRTC.framework/WebRTC on Device #371

Open mohit-kapadia-at-lirisoft opened 2 months ago

mohit-kapadia-at-lirisoft commented 2 months ago

Describe the bug App crashes while running on a physical device. Added a sample project(TestLiveKitIntegration.zip) to run and reproduce.

SDK Version 1.1.6, Adding the sdk using SPM under a sub project. Added screenshot. Even tried the latest version 2.0.6

iOS/macOS Version 17.3(iPhone 13 Pro Max)

Steps to Reproduce

Expected behavior App Crashes on launch on device. It should not crash.

Screenshots Addeed Screenshots

Logs dyld[579]: Library not loaded: @rpath/WebRTC.framework/WebRTC Referenced from: <0918C798-1BD0-368A-AAFD-3861F4093113> /private/var/containers/Bundle/Application/A0EED870-68BD-494C-9417-705F03C8BEC8/TestLiveKitIntegration.app/Frameworks/SubProjectFramework.framework/SubProjectFramework Reason: tried: '/Users/newuser/Library/Developer/Xcode/DerivedData/TestLiveKitIntegration-cqtlgdcnzeuwukgnvurxufzyqtdc/Build/Products/Debug-iphoneos/PackageFrameworks/WebRTC.framework/WebRTC' (no such file), '/private/preboot/Cryptexes/OS/Users/newuser/Library/Developer/Xcode/DerivedData/TestLiveKitIntegration-cqtlgdcnzeuwukgnvurxufzyqtdc/Build/Products/Debug-iphoneos/PackageFrameworks/WebRTC.framework/WebRTC' (no such file), '/private/var/containers/Bundle/Application/A0EED870-68BD-494C-9417-705F03C8BEC8/TestLiveKitIntegration.app/Frameworks/WebRTC.framework/WebRTC' (no such file), '/private/var/containers/Bundle/Application/A0EED870-68BD-494C-9417-705F03C8BEC8/TestLiveKitIntegration.app/Frameworks/SubProjectFramework.framework/Frameworks/WebRTC.framework/WebRTC' (no such file), '/Users/newuser/Library/Developer/Xcode/DerivedData/TestLiveKitIntegration-cqtlgdcnzeuwukgnvurxufzyqtdc/Build/Products/Debug-iphoneos/PackageFrameworks/WebRTC.framework/WebRTC' (no such file), '/private/preboot/Cryptexes/OS/Users/newuser/Library/Developer/Xcode/DerivedData/TestLiveKitIntegration-cqtlgdcnzeuwukgnvurxufzyqtdc/Build/Products/Debug-iphoneos/PackageFrameworks/WebRTC.framework/WebRTC' (no such file), '/private/var/containers/Bundle/Application/A0EED870-68BD-494C-9417-705F03C8BEC8/TestLiveKitIntegration.app/Frameworks/WebRTC.framework/WebRTC' (no such file), '/Users/newuser/Library/Developer/Xcode/DerivedData/TestLiveKitIntegration-cqtlgdcnzeuwukgnvurxufzyqtdc/Build/Products/Debug-iphoneos/PackageFrameworks/WebRTC.framework/WebRTC' (no such file), '/private/preboot/Cryptexes/OS/Users/newuser/Library/Developer/Xcode/DerivedData/TestLiveKitIntegration-cqtlgdcnzeuwukgnvurxufzyqtdc/Build/Products/Debug-iphoneos/PackageFrameworks/WebRTC.framework/WebRTC' (no such file), '/private/var/containers/Bundle/Application/A0EED870-68BD-494C-9417-705F03C8BEC8/TestLiveKitIntegration.app/Frameworks/WebRTC.framework/WebRTC' (no such file)

Screenshot 2024-05-03 at 7 25 17 PM

TestLiveKitIntegration.zip

davidzhao commented 2 months ago

Please remove WebRTC as a dependency, we no longer reference it in v2

mohit-kapadia-at-lirisoft commented 2 months ago

We have not added it explicitly, LiveKit is adding it as its own dependency. Pls check this screenshot.

Screenshot 2024-05-05 at 11 14 45 AM
davidzhao commented 2 months ago

you'll want to point it at 2.0, which has the following deps

    dependencies: [
        // LK-Prefixed Dynamic WebRTC XCFramework
        .package(url: "https://github.com/livekit/webrtc-xcframework.git", exact: "114.5735.14"),
        .package(url: "https://github.com/apple/swift-protobuf.git", from: "1.26.0"),
        .package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"),
        // Only used for DocC generation
        .package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.3.0"),
        // Only used for Testing
        .package(url: "https://github.com/vapor/jwt-kit.git", from: "4.13.4"),
    ],
mohit-kapadia-at-lirisoft commented 1 month ago

Thanks for responding so quickly, I see the same in latest version. The problem is with adding the dependency in a subproject which is a framework project not an iOS app project.

Pls check the screenshot, or if you can try the sample that I have added in earlier comment, you can reproduce it.

Screenshot 2024-05-06 at 11 28 20 AM
codin-play commented 2 weeks ago

I think I may have the same issue as you @mohit-kapadia-at-lirisoft . Did you determine a way around this?

hiroshihorie commented 2 weeks ago

Hello, sorry for the late reply. I can reproduce this issue with the device, the simulator is fine.

I think this is an unfortunate bug with the Swift Package Manager: https://github.com/airbnb/lottie-ios/issues/2233 https://github.com/apple/swift-package-manager/issues/6069

For now, if you want to use the SDK in a sub project, it looks like you will have to write a script to manually copy the LiveKitWebRTC.xcframework to your app's Framework directory. (as described in the above links)

The "add @executable_path/Frameworks to Runpaths" workaround doesn't seem to work. (already added in your sample project)