wang-bin / fvp

Flutter video player plugin for all desktop+mobile platforms. download prebuilt examples from github actions. https://pub.dev/packages/fvp
BSD 3-Clause "New" or "Revised" License
197 stars 31 forks source link

[iOS] How to include ass.framework? #173

Closed JulienDev closed 2 weeks ago

JulienDev commented 3 weeks ago

Describe the bug I want to be able to display subtitles on iOS but I cannot make it work. I followed the readme documentation, and tried to include libass framework but unfortunately I didn't succeed.

For example, I tried to:

dyld[1093]: Library not loaded: @rpath/Ass.framework/Ass Referenced from: /private/var/containers/Bundle/Application/6C96FD15-F54E-41AD-841D-84D353C4F4BC/Runner.app/Runner.debug.dylib Reason: tried: '/usr/lib/swift/Ass.framework/Ass' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/6C96FD15-F54E-41AD-841D-84D353C4F4BC/Runner.app/Frameworks/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/6C96FD15-F54E-41AD-841D-84D353C4F4BC/Runner.app/Frameworks/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/6C96FD15-F54E-41AD-841D-84D353C4F4BC/Runner.app/Ass.framework/Ass' (no such file), '/usr/lib/swift/Ass.framework/Ass' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/6C96FD15-F54E-41AD-841D-84D353C4F4BC/Runner.app/Frameworks/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/6C96FD15-F54E-41AD-841D-84D353C4F4BC/Runner.app/Frameworks/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/6C96FD15-F54E-41AD-841D-84D353C4F4BC/Runner.app/Ass.framework/Ass' (no such file), '/usr/lib/swift/Ass.framework/Ass' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/6C96FD15-F54E-41AD-841D-84D353C4F4BC/Runner.app/Frameworks/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/6C96FD15-F54E-41AD-841D-84D353C4F4BC/Runner.app/Frameworks/Ass.framework/Ass' (no such file) Message from debugger: killed

  • Renamed ass.framework to Ass.framework -> Not working
  • Added ass.framework to the target with embedding -> Can't build due to this error Multiple commands produce '/Users/julien/Library/Developer/Xcode/DerivedData/Runner-djikgrsclqaypsfkeehwwdcbprkp/Build/Products/Debug-iphoneos/Runner.app/Frameworks/Ass.framework' Target 'Runner' (project 'Runner') has copy command from '/Users/julien/projects/iptv-expert/expert/ios/Ass.framework' to '/Users/julien/Library/Developer/Xcode/DerivedData/Runner-djikgrsclqaypsfkeehwwdcbprkp/Build/Products/Debug-iphoneos/Runner.app/Frameworks/Ass.framework' That command depends on command in Target 'Runner' (project 'Runner'): script phase “[CP] Embed Pods Frameworks”

I'm not sure what I'm doing wrong. Could you please provide a guide on how to make it work on iOS? Or could you integrate it in the example app? Btw, what's the reason for not including libass directly in the iOS lib?

Thanks for your support!

wang-bin commented 3 weeks ago

I don't know why it's looking for Ass.framework, it should be ass.framework. Can you enable the log and show me complete log?

JulienDev commented 3 weeks ago

This is the only log I get, as it's crashing just before the app is launched on the device

wang-bin commented 3 weeks ago

did you enable the log following the issue template? if no ass.framework, it should not crash, just no subtitle rendered. debugging in lldb or xcode is also required for crash.

JulienDev commented 3 weeks ago

Let me add some details:

Screenshot 2024-10-27 at 11 24 23
flutter: mdk.FINE: 11:15:56.315: Failed to load libass runtime
flutter: mdk.FINE: 11:15:56.315: symbol not found: ass_library_init

Full Logs: https://pastebin.com/zbLD8Tfp.

When the app is launchign, the app is crashing instantly. There is no dart log printed in the console.

dyld[1969]: Library not loaded: @rpath/Ass.framework/Ass Referenced from: /private/var/containers/Bundle/Application/9A0F882A-350D-4874-8233-549723759051/Runner.app/Runner.debug.dylib Reason: tried: '/usr/lib/swift/Ass.framework/Ass' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/9A0F882A-350D-4874-8233-549723759051/Runner.app/Frameworks/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/9A0F882A-350D-4874-8233-549723759051/Runner.app/Frameworks/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/9A0F882A-350D-4874-8233-549723759051/Runner.app/Ass.framework/Ass' (no such file), '/usr/lib/swift/Ass.framework/Ass' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/9A0F882A-350D-4874-8233-549723759051/Runner.app/Frameworks/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/9A0F882A-350D-4874-8233-549723759051/Runner.app/Frameworks/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/9A0F882A-350D-4874-8233-549723759051/Runner.app/Ass.framework/Ass' (no such file), '/usr/lib/swift/Ass.framework/Ass' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/9A0F882A-350D-4874-8233-549723759051/Runner.app/Frameworks/Ass.framework/Ass' (no such file), '/private/var/containers/Bundle/Application/9A0F882A-350D-4874-8233-549723759051/Runner.app/Frameworks/Ass.framework/Ass' (no such file)

wang-bin commented 3 weeks ago

I run ios example on my m1 mac, can't reproduce your crash if Embed & Sign. Run otool -L $app_executable shows @rpath/ass.framework/ass (compatibility version 9.0.0, current version 0.17.2) but not Ass.framework. If I add environment variables DYLD_PRINT_LIBRARIES with value 1 in xcode->product->scheme->edit scheme->run->arguments->environment variables, console shows all libraries try to load, including ass.framework:

dyld[87478]: <368D5F50-8435-3AE6-A8F3-9BB44045441F> /private/var/folders/cm/zh7xx2js7kq1gjvvjr_lx7hc0000gn/X/F9E10E5D-0AFF-5C40-A58E-C4DE1D9A74A6/d/Wrapper/Runner.app/Frameworks/ass.framework/ass
JulienDev commented 3 weeks ago

Thanks for you investigation @wang-bin Now I understand the issue. In my app I'm embedding two players, media-kit and fvp so the user can select the player he prefers to use. It looks like media-kit is looking for a libass under Ass.framework/Ass name while fvp needs ass.framework/ass. When I remove media-kit from the project, the app is able to launch successfully and FVP subtitles are displayed.

Do you have a solution in mind to make it work? I really want to keep both players in my app. I tried to create a symbolic link but it's not possible on MacOS:

ln -s ass.framework/ass Ass.framework/Ass
ln: Ass.framework/Ass: File exists
wang-bin commented 3 weeks ago

media-kit provides Ass.framework, dont delete it. if you want to use ass.framework for media kit, copy to Ass.framework, and use install_name_tool to change id of Ass.framework/Ass. if your filesystem is case insensitive, the only solution is using the same name in both projects, i can try to add Ass.framework as a dependency

JulienDev commented 3 weeks ago

Not sure to understand the install_name_tool solution but yes indeed, could be great if Ass.framework could be used by FVP too.

Btw I didn't delete Ass.framework, I think xcode removed it automatically when he noticed that I'm embedding Ass and ass

wang-bin commented 3 weeks ago

upgrade the dependencies, then should be compatible eith Ass.framework, and ass.framework is not required in your case

JulienDev commented 2 weeks ago

Sorry for the delay, it works perfectly, thank you so much!